Sha256: bec436cde93d61fe6ef30733f6ab1144098700a797caac3019ae6cc5da4338fd

Contents?: true

Size: 982 Bytes

Versions: 17

Compression:

Stored size: 982 Bytes

Contents

RSpec::Matchers.define :transition_from do |from_state|
  match do |obj|
    @state_machine_name ||= :default
    obj.aasm(@state_machine_name).current_state = from_state.to_sym
    obj.send(@event, *@args) && obj.aasm(@state_machine_name).current_state == @to_state.to_sym
  end

  chain :on do |state_machine_name|
    @state_machine_name = state_machine_name
  end

  chain :to do |state|
    @to_state = state
  end

  chain :on_event do |event, *args|
    @event = event
    @args = args
  end

  description do
    "transition state to :#{@to_state} from :#{expected} on event :#{@event}, with params: #{@args} (on :#{@state_machine_name})"
  end

  failure_message do |obj|
    "expected that :#{obj.aasm(@state_machine_name).current_state} would be :#{@to_state} (on :#{@state_machine_name})"
  end

  failure_message_when_negated do |obj|
    "expected that :#{obj.aasm(@state_machine_name).current_state} would not be :#{@to_state} (on :#{@state_machine_name})"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aasm-5.0.6 lib/aasm/rspec/transition_from.rb
aasm-5.0.5 lib/aasm/rspec/transition_from.rb
aasm-5.0.4 lib/aasm/rspec/transition_from.rb
aasm-5.0.3 lib/aasm/rspec/transition_from.rb
aasm-5.0.2 lib/aasm/rspec/transition_from.rb
aasm-5.0.1 lib/aasm/rspec/transition_from.rb
aasm-5.0.0 lib/aasm/rspec/transition_from.rb
aasm-4.12.3 lib/aasm/rspec/transition_from.rb
aasm-4.12.2 lib/aasm/rspec/transition_from.rb
aasm-4.12.1 lib/aasm/rspec/transition_from.rb
aasm-4.12.0 lib/aasm/rspec/transition_from.rb
aasm-4.11.1 lib/aasm/rspec/transition_from.rb
aasm-4.11.0 lib/aasm/rspec/transition_from.rb
aasm-4.10.1 lib/aasm/rspec/transition_from.rb
aasm-4.10.0 lib/aasm/rspec/transition_from.rb
aasm-4.9.0 lib/aasm/rspec/transition_from.rb
aasm-4.8.0 lib/aasm/rspec/transition_from.rb