Class: Flow::CustomMatchers::HaveOnState
- Inherits:
-
Object
- Object
- Flow::CustomMatchers::HaveOnState
- Includes:
- RSpec::Matchers
- Defined in:
- lib/flow/rspec/custom_matchers/have_on_state.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(state_expectations) ⇒ HaveOnState
constructor
A new instance of HaveOnState.
- #matches?(object) ⇒ Boolean
Constructor Details
#initialize(state_expectations) ⇒ HaveOnState
Returns a new instance of HaveOnState.
41 42 43 |
# File 'lib/flow/rspec/custom_matchers/have_on_state.rb', line 41 def initialize(state_expectations) @state_expectations = state_expectations end |
Instance Method Details
#description ⇒ Object
56 57 58 |
# File 'lib/flow/rspec/custom_matchers/have_on_state.rb', line 56 def description "have the expected data on state" end |
#matches?(object) ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/flow/rspec/custom_matchers/have_on_state.rb', line 45 def matches?(object) @state_expectations.all? do |key, value| # If state is actually a StateProxy, we to access the state directly with _state if object.state.respond_to?(:_state, true) expect(object.state.__send__(:_state).public_send(key)).to match value else expect(object.state.public_send(key)).to match value end end end |