Class: TarkaMatchers::Matchers::Class::HaveAnInstanceVariableOf
- Defined in:
- lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(instance_name) ⇒ HaveAnInstanceVariableOf
constructor
A new instance of HaveAnInstanceVariableOf.
- #matches?(actual) ⇒ Boolean
- #that_equals(expected) ⇒ Object
Constructor Details
#initialize(instance_name) ⇒ HaveAnInstanceVariableOf
Returns a new instance of HaveAnInstanceVariableOf.
11 12 13 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 11 def initialize instance_name @instance_name = instance_name end |
Instance Method Details
#description ⇒ Object
25 26 27 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 25 def description "contain an instance variable called, '#{@instance_name}', that equals '#{@expected}'." end |
#failure_message ⇒ Object
29 30 31 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 29 def "failed to #{description}\n#{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}" end |
#failure_message_when_negated ⇒ Object
33 34 35 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 33 def "did #{description}" end |
#matches?(actual) ⇒ Boolean
20 21 22 23 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 20 def matches? actual @actual = actual.instance_variable_get(@instance_name) @actual == @expected end |
#that_equals(expected) ⇒ Object
15 16 17 18 |
# File 'lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb', line 15 def that_equals expected @expected = expected self end |