Skip to content

Commit

Permalink
Merge pull request #47 from paulspringett/fix-transition-to-swallowin…
Browse files Browse the repository at this point in the history
…g-user-exceptions

Fix transition to swallowing user exceptions
  • Loading branch information
appleton committed May 19, 2014
2 parents 27793c3 + c5f58ab commit f0ddf20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/statesman/machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def execute(phase, initial_state, new_state, transition)

def transition_to(new_state, metadata = nil)
self.transition_to!(new_state, metadata)
rescue
rescue TransitionFailedError, GuardFailedError
false
end

Expand Down
15 changes: 15 additions & 0 deletions spec/statesman/machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,21 @@ def after_initialize; end
end
it { should be_false }
end

context "when a non statesman exception is raised" do
before do
instance.stub(:transition_to!).and_raise(RuntimeError,
'user defined exception')
end

it "should not rescue the exception" do
expectation = expect do
instance.transition_to(:some_state, metadata)
end

expectation.to raise_error(RuntimeError, 'user defined exception')
end
end
end

shared_examples "a callback filter" do |definer, phase|
Expand Down

0 comments on commit f0ddf20

Please sign in to comment.