Class: ShouldaRenderJsonObjectMatcher
- Inherits:
-
Object
- Object
- ShouldaRenderJsonObjectMatcher
- Defined in:
- lib/shoulda_render_json_object_matcher.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#negative_failure_message ⇒ Object
readonly
Returns the value of attribute negative_failure_message.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(root, options = {}) ⇒ ShouldaRenderJsonObjectMatcher
constructor
A new instance of ShouldaRenderJsonObjectMatcher.
- #matches?(controller) ⇒ Boolean
Constructor Details
#initialize(root, options = {}) ⇒ ShouldaRenderJsonObjectMatcher
Returns a new instance of ShouldaRenderJsonObjectMatcher.
4 5 6 7 8 9 10 11 12 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 4 def initialize(root, = {}) = # Coercing types root: Symbol, keys: Array of Symbols @root = root.to_s @keys = { required: (:required), forbidden: (:forbidden), } end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def context @context end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def keys @keys end |
#negative_failure_message ⇒ Object (readonly)
Returns the value of attribute negative_failure_message.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def response @response end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
2 3 4 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 2 def root @root end |
Instance Method Details
#description ⇒ Object
14 15 16 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 14 def description "render JSON Hash/Object for #{@root}" end |
#matches?(controller) ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/shoulda_render_json_object_matcher.rb', line 18 def matches?(controller) @response = controller.response matches_content_type? && matches_root? && has_required_keys? && has_no_forbidden_keys? end |