M lib/pushdown/spec_helpers.rb +2 -2
@@ 103,9 103,9 @@ module Pushdown::SpecHelpers
### Specify that the operation that should cause the transition is the #on_event callback.
- def on_an_event( event )
+ def on_an_event( event, *args )
raise ScriptError, "can't specify more than one callback" if self.callback
- @callback = [ :on_event, event ]
+ @callback = [ :on_event, event, *args ]
return self
end
alias_method :on_event, :on_an_event
M pushdown.gemspec +3 -3
@@ 1,15 1,15 @@
# -*- encoding: utf-8 -*-
-# stub: pushdown 0.3.0.pre.20210901151908 ruby lib
+# stub: pushdown 0.4.0.pre.20210902144834 ruby lib
Gem::Specification.new do |s|
s.name = "pushdown".freeze
- s.version = "0.3.0.pre.20210901151908"
+ s.version = "0.4.0.pre.20210902144834"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
s.metadata = { "bug_tracker_uri" => "http://todo.sr.ht/~ged/Pushdown", "changelog_uri" => "http://deveiate.org/code/pushdown/History_md.html", "documentation_uri" => "http://deveiate.org/code/pushdown", "homepage_uri" => "http://hg.sr.ht/~ged/Pushdown", "source_uri" => "http://hg.sr.ht/~ged/Pushdown" } if s.respond_to? :metadata=
s.require_paths = ["lib".freeze]
s.authors = ["Michael Granger".freeze]
- s.date = "2021-09-01"
+ s.date = "2021-09-02"
s.description = "A pushdown automaton toolkit for Ruby. It's based on the State Manager from the Amethyst project.".freeze
s.email = ["ged@faeriemud.org".freeze]
s.files = ["History.md".freeze, "LICENSE.txt".freeze, "README.md".freeze, "lib/pushdown.rb".freeze, "lib/pushdown/automaton.rb".freeze, "lib/pushdown/exceptions.rb".freeze, "lib/pushdown/spec_helpers.rb".freeze, "lib/pushdown/state.rb".freeze, "lib/pushdown/transition.rb".freeze, "lib/pushdown/transition/pop.rb".freeze, "lib/pushdown/transition/push.rb".freeze, "lib/pushdown/transition/replace.rb".freeze, "lib/pushdown/transition/switch.rb".freeze, "spec/pushdown/automaton_spec.rb".freeze, "spec/pushdown/spec_helpers_spec.rb".freeze, "spec/pushdown/state_spec.rb".freeze, "spec/pushdown/transition/pop_spec.rb".freeze, "spec/pushdown/transition/push_spec.rb".freeze, "spec/pushdown/transition/replace_spec.rb".freeze, "spec/pushdown/transition/switch_spec.rb".freeze, "spec/pushdown/transition_spec.rb".freeze, "spec/pushdown_spec.rb".freeze, "spec/spec_helper.rb".freeze]
M spec/pushdown/spec_helpers_spec.rb +13 -0
@@ 352,6 352,19 @@ RSpec.describe( Pushdown::SpecHelpers )
end
+ it "supports giving additional arguments to pass the #on_event operation" do
+ state_class.transition_push( :change, :other )
+
+ state = state_class.new
+ expect( state ).to receive( :on_event ).with( :foo, 1, "another arg" ).
+ and_return( :change )
+
+ expect {
+ expect( state ).to transition.on_an_event( :foo, 1, "another arg" )
+ }.to_not raise_error
+ end
+
+
it "adds the callback to the description if on_update is specified" do
state_class.transition_push( :change, :other )