pushdown 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07c713124675b07b3fdb91a1e7a9c2f0386899c2e37ca1b820ddbce6aaa5ea8e
4
- data.tar.gz: f3c40b62850afe641934d6a77ffec9011809df10648c073242de1d65646f7578
3
+ metadata.gz: 07f7a5dfc7c5783cd2fe4e7e610467519ef85ed1a7ff857bce91c58805f6f457
4
+ data.tar.gz: 02a41fb1852f955d282834ea9ff397d98bb66681f3a7f38b26e13d00503a89dc
5
5
  SHA512:
6
- metadata.gz: 7957d836aaf103e2e45da26ab088ff66709c3463f2e630f9d4e1cc14e07519cc147359db0a622c659d6dc5b02ef57b374434b7816cee5f519ca9a58d57a0d140
7
- data.tar.gz: 5e1c5467df6a41e86a797d4b783e07684296cb252ca241f284360ee0d4677a1413fe9974e7f63ccd2cda1fdfae6a970fada1158ea9dcc108382fe1ac45bb33aa
6
+ metadata.gz: 537d7f75b6265b4a08b20b67d9f547a42b27514e18d46a7dc9d3bd0f2066ae8161424bf92f39d2c25ad8dca2762a3731deb368c259f26c65004e26244a388f54
7
+ data.tar.gz: b5398fee7bc5fe436f39c8ad760118fd6178baadf13362e85402b442fd609d10b5a5b6d73c2b04a49700ab30641be4d4d190d156e5622c0de9ffe19d9557b965
checksums.yaml.gz.sig CHANGED
Binary file
data/History.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Release History for pushdown
2
2
 
3
3
  ---
4
+ ## v0.4.0 [2021-09-21] Michael Granger <ged@faeriemud.org>
5
+
6
+ Improvements:
7
+
8
+ - Report operator arguments in the spec matcher failure output.
9
+ - Allow the State event callback to accept additional arguments.
10
+
11
+
4
12
  ## v0.3.0 [2021-09-01] Michael Granger <ged@faeriemud.org>
5
13
 
6
14
  Change:
@@ -103,9 +103,9 @@ module Pushdown::SpecHelpers
103
103
 
104
104
 
105
105
  ### Specify that the operation that should cause the transition is the #on_event callback.
106
- def on_an_event( event )
106
+ def on_an_event( event, *args )
107
107
  raise ScriptError, "can't specify more than one callback" if self.callback
108
- @callback = [ :on_event, event ]
108
+ @callback = [ :on_event, event, *args ]
109
109
  return self
110
110
  end
111
111
  alias_method :on_event, :on_an_event
@@ -182,9 +182,9 @@ module Pushdown::SpecHelpers
182
182
  desc << " to %s" % [ self.target_state ] if self.target_state
183
183
 
184
184
  if self.callback
185
- methname, arg = self.callback
185
+ methname, *args = self.callback
186
186
  desc << " when #%s is called" % [ methname ]
187
- desc << " with %p" % [ arg ] if arg
187
+ desc << " with %s" % [ args.map(&:inspect).join(', ') ] if !args.empty?
188
188
  end
189
189
 
190
190
  desc << ', but '
@@ -107,7 +107,7 @@ class Pushdown::State
107
107
 
108
108
  ### Event callback -- called by the automaton when its #on_<stackname>_event method
109
109
  ### is called. This method can return a Transition or a Symbol which maps to one.
110
- def on_event( event )
110
+ def on_event( event, *args )
111
111
  return nil # no-op
112
112
  end
113
113
 
data/lib/pushdown.rb CHANGED
@@ -15,7 +15,7 @@ module Pushdown
15
15
  extend Loggability
16
16
 
17
17
  # Package version
18
- VERSION = '0.3.0'
18
+ VERSION = '0.4.0'
19
19
 
20
20
 
21
21
  # Loggability API -- create a logger for Pushdown classes and modules
@@ -352,6 +352,19 @@ RSpec.describe( Pushdown::SpecHelpers ) do
352
352
  end
353
353
 
354
354
 
355
+ it "supports giving additional arguments to pass the #on_event operation" do
356
+ state_class.transition_push( :change, :other )
357
+
358
+ state = state_class.new
359
+ expect( state ).to receive( :on_event ).with( :foo, 1, "another arg" ).
360
+ and_return( :change )
361
+
362
+ expect {
363
+ expect( state ).to transition.on_an_event( :foo, 1, "another arg" )
364
+ }.to_not raise_error
365
+ end
366
+
367
+
355
368
  it "adds the callback to the description if on_update is specified" do
356
369
  state_class.transition_push( :change, :other )
357
370
 
@@ -373,6 +386,19 @@ RSpec.describe( Pushdown::SpecHelpers ) do
373
386
  }.to fail_matching( /transition when #on_event is called with :foo/i )
374
387
  end
375
388
 
389
+
390
+ it "handles multiple callback arguments on failures" do
391
+ state_class.transition_push( :change, :other )
392
+
393
+ state = state_class.new
394
+ allow( state ).to receive( :on_event ).with( :foo, 18, "nebraska" ).
395
+ and_return( nil )
396
+
397
+ expect {
398
+ expect( state ).to transition.on_an_event( :foo, 18, "nebraska" )
399
+ }.to fail_matching( /#on_event is called with :foo, 18, "nebraska"/i )
400
+ end
401
+
376
402
  end
377
403
 
378
404
  describe "negated matcher" do
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -33,7 +33,7 @@ cert_chain:
33
33
  MCh97sQ/Z/MOusb5+QddBmB+k8EicXyGNl4b5L4XpL7fIQu+Y96TB3JEJlShxFD9
34
34
  k9FjI4d9EP54gS/4
35
35
  -----END CERTIFICATE-----
36
- date: 2021-09-01 00:00:00.000000000 Z
36
+ date: 2021-09-21 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: loggability
metadata.gz.sig CHANGED
Binary file