Class: Test::Spec::Rails::Macros::Response::TestGenerator
- Defined in:
- lib/test/spec/rails/macros/response.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
Returns the value of attribute expected.
-
#message ⇒ Object
Returns the value of attribute message.
-
#status ⇒ Object
Returns the value of attribute status.
Attributes inherited from Proxy
Instance Method Summary collapse
-
#initialize(test_case, status, message) ⇒ TestGenerator
constructor
A new instance of TestGenerator.
- #method_missing(verb, action, params = {}) ⇒ Object
Constructor Details
#initialize(test_case, status, message) ⇒ TestGenerator
Returns a new instance of TestGenerator.
16 17 18 19 20 21 |
# File 'lib/test/spec/rails/macros/response.rb', line 16 def initialize(test_case, status, ) self.status = status self. = super(test_case) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(verb, action, params = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/test/spec/rails/macros/response.rb', line 23 def method_missing(verb, action, params={}) if [:get, :post, :put, :delete, :options].include?(verb.to_sym) description = "should not find resource with #{verb.to_s.upcase} on `#{action}'" description << " #{params.inspect}" unless params.blank? status = self.status = self. if defined?(:ActiveRecord) test_case.it description do begin send(verb, action, immediate_values(params)) status.should.messaging() == status rescue ActiveRecord::RecordNotFound :not_found.should.messaging() == status end end else test_case.it description do send(verb, action, immediate_values(params)) status.should.messaging() == status end end else super end end |
Instance Attribute Details
#expected ⇒ Object
Returns the value of attribute expected.
14 15 16 |
# File 'lib/test/spec/rails/macros/response.rb', line 14 def expected @expected end |
#message ⇒ Object
Returns the value of attribute message.
14 15 16 |
# File 'lib/test/spec/rails/macros/response.rb', line 14 def @message end |
#status ⇒ Object
Returns the value of attribute status.
14 15 16 |
# File 'lib/test/spec/rails/macros/response.rb', line 14 def status @status end |