Skip to content

Commit

Permalink
Merge pull request #280 from gocardless/v3.2.0
Browse files Browse the repository at this point in the history
Bump version to v3.2.0
  • Loading branch information
Tim Rogers authored Nov 28, 2017
2 parents c0378b4 + 10d4c9c commit c12a303
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

## v3.2.0, 27 November 2017

- Allow specifying metadata with `Machine#allowed_transitions` (patch by [@vvondra](https://github.com/vvondra))

## v3.1.0, 1 September 2017

- Add support for Rails 5.0.x and 5.1.x (patch by [@kenchan0130](https://github.com/kenchan0130) and [@timrogers](https://github.com/timrogers))
Expand Down
2 changes: 1 addition & 1 deletion lib/statesman/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Statesman
VERSION = "3.1.0".freeze
VERSION = "3.2.0".freeze
end
28 changes: 24 additions & 4 deletions spec/statesman/machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,22 @@ def after_initialize; end
it { is_expected.to eq(['z']) }

context "guarded using metadata" do
before { machine.guard_transition(to: :z) { |_, _, metadata | metadata[:some] == :metadata } }
before do
machine.guard_transition(to: :z) do |_, _, metadata|
metadata[:some] == :metadata
end
end

it { is_expected.to eq(['z']) }
end

context "excluded by guard using metadata" do
before { machine.guard_transition(to: :z) { |_, _, metadata | metadata[:some] != :metadata } }
before do
machine.guard_transition(to: :z) do |_, _, metadata|
metadata[:some] != :metadata
end
end

it { is_expected.to eq([]) }
end
end
Expand Down Expand Up @@ -529,12 +539,22 @@ def after_initialize; end
end

context "but it has a failing guard based on metadata" do
before { machine.guard_transition(to: :y) { |_, _, metadata | metadata[:some] != :metadata } }
before do
machine.guard_transition(to: :y) do |_, _, metadata|
metadata[:some] != :metadata
end
end

it { is_expected.to be_falsey }
end

context "and has a passing guard based on metadata" do
before { machine.guard_transition(to: :y) { |_, _, metadata | metadata[:some] == :metadata } }
before do
machine.guard_transition(to: :y) do |_, _, metadata|
metadata[:some] == :metadata
end
end

it { is_expected.to be_truthy }
end
end
Expand Down

0 comments on commit c12a303

Please sign in to comment.