Class: ActiveModel::Serializers::Matchers::HaveAttribute
- Inherits:
-
Object
- Object
- ActiveModel::Serializers::Matchers::HaveAttribute
- Defined in:
- lib/active_model_serializers/matchers.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
Returns the value of attribute actual.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(name) ⇒ HaveAttribute
constructor
A new instance of HaveAttribute.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ HaveAttribute
Returns a new instance of HaveAttribute.
85 86 87 |
# File 'lib/active_model_serializers/matchers.rb', line 85 def initialize(name) @name = name end |
Instance Attribute Details
#actual ⇒ Object
Returns the value of attribute actual.
83 84 85 |
# File 'lib/active_model_serializers/matchers.rb', line 83 def actual @actual end |
#name ⇒ Object
Returns the value of attribute name.
83 84 85 |
# File 'lib/active_model_serializers/matchers.rb', line 83 def name @name end |
Instance Method Details
#description ⇒ Object
95 96 97 |
# File 'lib/active_model_serializers/matchers.rb', line 95 def description "have attribute #{name}" end |
#failure_message_for_should ⇒ Object
99 100 101 |
# File 'lib/active_model_serializers/matchers.rb', line 99 def %Q{expected #{actual.inspect} to include "#{name}", but it did not} end |
#failure_message_for_should_not ⇒ Object
103 104 105 |
# File 'lib/active_model_serializers/matchers.rb', line 103 def %Q{expected #{actual.inspect} to not include: "#{name}", but it did} end |
#matches?(actual) ⇒ Boolean
89 90 91 92 93 |
# File 'lib/active_model_serializers/matchers.rb', line 89 def matches?(actual) @actual = actual attributes.has_key?(name) end |