diff --git a/CHANGELOG.md b/CHANGELOG.md index e0d962ef..dc7a09c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/lib/statesman/version.rb b/lib/statesman/version.rb index 097a4d5c..022dd565 100644 --- a/lib/statesman/version.rb +++ b/lib/statesman/version.rb @@ -1,3 +1,3 @@ module Statesman - VERSION = "3.1.0".freeze + VERSION = "3.2.0".freeze end diff --git a/spec/statesman/machine_spec.rb b/spec/statesman/machine_spec.rb index 108693ec..8bdd6bea 100644 --- a/spec/statesman/machine_spec.rb +++ b/spec/statesman/machine_spec.rb @@ -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 @@ -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