Class: ObjectProtocol::MessageExpectation
- Inherits:
-
Object
- Object
- ObjectProtocol::MessageExpectation
- Defined in:
- lib/object_protocol/message_expectation.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #arguments_specified? ⇒ Boolean
-
#initialize(protocol:, sender:, message:) ⇒ MessageExpectation
constructor
A new instance of MessageExpectation.
- #inspect ⇒ Object
- #to(receiver) ⇒ Object
- #to_rspec_matcher_failure_message_lines ⇒ Object
- #to_satisfiable ⇒ Object
- #with(*arguments) ⇒ Object
Constructor Details
#initialize(protocol:, sender:, message:) ⇒ MessageExpectation
Returns a new instance of MessageExpectation.
7 8 9 10 11 12 13 |
# File 'lib/object_protocol/message_expectation.rb', line 7 def initialize(protocol:, sender:, message:) @protocol = protocol @sender = sender @message = @arguments_specified = false end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/object_protocol/message_expectation.rb', line 5 def arguments @arguments end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/object_protocol/message_expectation.rb', line 5 def @message end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
5 6 7 |
# File 'lib/object_protocol/message_expectation.rb', line 5 def receiver @receiver end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
5 6 7 |
# File 'lib/object_protocol/message_expectation.rb', line 5 def sender @sender end |
Instance Method Details
#==(other) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/object_protocol/message_expectation.rb', line 47 def ==(other) other.respond_to?(:sender) && sender == other.sender && other.respond_to?(:receiver) && receiver == other.receiver && other.respond_to?(:message) && == other. && other.respond_to?(:arguments) && arguments == other.arguments end |
#arguments_specified? ⇒ Boolean
58 59 60 |
# File 'lib/object_protocol/message_expectation.rb', line 58 def arguments_specified? @arguments_specified end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/object_protocol/message_expectation.rb', line 33 def inspect "<#{self.class.name.split('::').last}[#{sender.name}, :#{}, #{receiver.name}]>" end |
#to(receiver) ⇒ Object
15 16 17 18 19 |
# File 'lib/object_protocol/message_expectation.rb', line 15 def to(receiver) @receiver = receiver self end |
#to_rspec_matcher_failure_message_lines ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/object_protocol/message_expectation.rb', line 37 def fragment_base = "#{sender.name}.sends(:#{}).to(#{receiver.name})" if arguments_specified? ["#{fragment_base}.with(#{arguments})"] else [fragment_base] end end |
#to_satisfiable ⇒ Object
29 30 31 |
# File 'lib/object_protocol/message_expectation.rb', line 29 def to_satisfiable SatisfiableMessageExpectation.new(protocol: protocol, message_expectation: self) end |
#with(*arguments) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/object_protocol/message_expectation.rb', line 21 def with(*arguments) @arguments = arguments @arguments_specified = true self end |