Class: Test::Spec::Rails::Macros::Authorization::TestGenerator
- Defined in:
- lib/test/spec/rails/macros/authorization.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
Returns the value of attribute expected.
-
#message ⇒ Object
Returns the value of attribute message.
-
#validation_method ⇒ Object
Returns the value of attribute validation_method.
Attributes inherited from Proxy
Instance Method Summary collapse
-
#initialize(test_case, validation_method, expected, message) ⇒ TestGenerator
constructor
A new instance of TestGenerator.
- #method_missing(verb, action, params = {}) ⇒ Object
Constructor Details
#initialize(test_case, validation_method, expected, message) ⇒ TestGenerator
Returns a new instance of TestGenerator.
48 49 50 51 52 53 54 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 48 def initialize(test_case, validation_method, expected, ) self.validation_method = validation_method self.expected = expected self. = super(test_case) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(verb, action, params = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 56 def method_missing(verb, action, params={}) if [:get, :post, :put, :delete, :options].include?(verb.to_sym) description = "should disallow #{verb.to_s.upcase} on `#{action}'" description << " #{params.inspect}" unless params.blank? validation_method = self.validation_method expected = self.expected = self. test_case.it description do send(verb, action, immediate_values(params)) send(validation_method).should.messaging() == expected end else super end end |
Instance Attribute Details
#expected ⇒ Object
Returns the value of attribute expected.
46 47 48 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 46 def expected @expected end |
#message ⇒ Object
Returns the value of attribute message.
46 47 48 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 46 def @message end |
#validation_method ⇒ Object
Returns the value of attribute validation_method.
46 47 48 |
# File 'lib/test/spec/rails/macros/authorization.rb', line 46 def validation_method @validation_method end |