class Flow::CustomMatchers::HaveOnState

Public Class Methods

new(state_expectations) click to toggle source
# File lib/flow/rspec/custom_matchers/have_on_state.rb, line 41
def initialize(state_expectations)
  @state_expectations = state_expectations
end

Public Instance Methods

description() click to toggle source
# File lib/flow/rspec/custom_matchers/have_on_state.rb, line 56
def description
  "have the expected data on state"
end
matches?(object) click to toggle source
# 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