Skip to content

Commit

Permalink
Add posibility to pass arguments to on_event rspec custom matcher fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
zacviandier committed Jan 16, 2016
1 parent bdf7e4c commit 131d9f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/aasm/rspec/transition_from.rb
Expand Up @@ -2,8 +2,7 @@
match do |obj|
@state_machine_name ||= :default
obj.aasm(@state_machine_name).current_state = from_state.to_sym
# expect(obj).to receive(:broadcast_event).with(@event.to_s, obj, from_state, @to_state)
obj.send(@event) && obj.aasm(@state_machine_name).current_state == @to_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|
Expand All @@ -14,12 +13,13 @@
@to_state = state
end

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

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

failure_message do |obj|
Expand Down

0 comments on commit 131d9f3

Please sign in to comment.