Class: Stenotype::Test::Matchers::EventHasExpectedArguments
- Inherits:
-
Object
- Object
- Stenotype::Test::Matchers::EventHasExpectedArguments
- Defined in:
- lib/stenotype/test/matchers.rb
Instance Attribute Summary collapse
-
#expected_arguments ⇒ Object
readonly
Returns the value of attribute expected_arguments.
-
#matching_events ⇒ Object
readonly
Returns the value of attribute matching_events.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(matching_events, expected_arguments) ⇒ EventHasExpectedArguments
constructor
A new instance of EventHasExpectedArguments.
- #matches? ⇒ Boolean
Constructor Details
#initialize(matching_events, expected_arguments) ⇒ EventHasExpectedArguments
Returns a new instance of EventHasExpectedArguments.
29 30 31 32 |
# File 'lib/stenotype/test/matchers.rb', line 29 def initialize(matching_events, expected_arguments) @matching_events = matching_events @expected_arguments = stringify_keys(expected_arguments) end |
Instance Attribute Details
#expected_arguments ⇒ Object (readonly)
Returns the value of attribute expected_arguments.
27 28 29 |
# File 'lib/stenotype/test/matchers.rb', line 27 def expected_arguments @expected_arguments end |
#matching_events ⇒ Object (readonly)
Returns the value of attribute matching_events.
27 28 29 |
# File 'lib/stenotype/test/matchers.rb', line 27 def matching_events @matching_events end |
Instance Method Details
#failure_message ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/stenotype/test/matchers.rb', line 40 def if multiple_events? "more than one event with given event name has been emitted. Can not match event arguments" else "expected to see all attributes from #{expected_arguments} to be included in event attributes but got #{matching_event}" end end |
#matches? ⇒ Boolean
34 35 36 37 38 |
# File 'lib/stenotype/test/matchers.rb', line 34 def matches? return false if multiple_events? (expected_arguments.to_a - matching_event.to_a).empty? end |