Class: Catechism::Matchers::Send
- Defined in:
- lib/catechism/matchers/send.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#negated ⇒ Object
Returns the value of attribute negated.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/catechism/matchers/send.rb', line 3 def arguments @arguments end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
3 4 5 |
# File 'lib/catechism/matchers/send.rb', line 3 def destination @destination end |
#method_name ⇒ Object
Returns the value of attribute method_name
2 3 4 |
# File 'lib/catechism/matchers/send.rb', line 2 def method_name @method_name end |
#negated ⇒ Object
Returns the value of attribute negated
2 3 4 |
# File 'lib/catechism/matchers/send.rb', line 2 def negated @negated end |
#subject ⇒ Object
Returns the value of attribute subject
2 3 4 |
# File 'lib/catechism/matchers/send.rb', line 2 def subject @subject end |
Instance Method Details
#failure_message ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/catechism/matchers/send.rb', line 29 def if negated "Expected #{destination} not to receive #{method_name}, but got it anyway" else "Expected #{method_name} on #{destination}, but was not received" end end |
#to(destination) ⇒ Object
5 6 7 8 |
# File 'lib/catechism/matchers/send.rb', line 5 def to(destination) @destination = destination raise unless valid? end |
#valid? ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/catechism/matchers/send.rb', line 15 def valid? called = false send_matcher = self destination.class.send(:define_method, method_name) do |*args| if !send_matcher.arguments.nil? called = send_matcher.arguments == args else called = true end end subject.call called ^ negated end |
#with(*arguments) ⇒ Object
10 11 12 13 |
# File 'lib/catechism/matchers/send.rb', line 10 def with(*arguments) @arguments = arguments self end |