ruby_valve 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +4 -4
- data/lib/ruby_valve/version.rb +1 -1
- data/spec/lib/base_spec.rb +44 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b8f2c19f9c27eb98876a7d17762a72bd3aabe6e
|
4
|
+
data.tar.gz: c2464b0627d5b46a1258483ebf08de8ebc43af9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89314afbeab98957cc74e86902ab0a051c7ced0e416a77fbcd6082640e4f56231a9a7f243888fccad362ea2e7934dbba60dea990af0a0b4e0508e8c32dec101a
|
7
|
+
data.tar.gz: 74242411a418b50dfb041d65fd52ded3d352271820d1ab1ad8de21bea27bdc3b904105c5e8479f8d6864371c45fc6d829709cea25b088fbd969e267a9d4e391b
|
data/README.md
CHANGED
@@ -264,8 +264,8 @@ Executes if an abort, without a raise, was triggered.
|
|
264
264
|
|
265
265
|
aborted!
|
266
266
|
|
267
|
-
####\#
|
268
|
-
Creating an
|
267
|
+
####\#after_exception and #exception
|
268
|
+
Creating an after_exception method will trigger an automatic rescue when an error is raised. The exception is stored in the **exception** method.
|
269
269
|
|
270
270
|
def step_1
|
271
271
|
abort "call it off", raise: true
|
@@ -275,7 +275,7 @@ Creating an after_raise method will trigger an automatic rescue when an error is
|
|
275
275
|
puts "E"
|
276
276
|
end
|
277
277
|
|
278
|
-
def
|
278
|
+
def after_exception
|
279
279
|
puts exception.message
|
280
280
|
end
|
281
281
|
|
@@ -325,7 +325,7 @@ This will display each step and callback method that was executed.
|
|
325
325
|
|
326
326
|
foo = Foo.new
|
327
327
|
foo.execute
|
328
|
-
foo.
|
328
|
+
foo.executed
|
329
329
|
|
330
330
|
[:step_1, :after_each, :step_2, :after_each]
|
331
331
|
|
data/lib/ruby_valve/version.rb
CHANGED
data/spec/lib/base_spec.rb
CHANGED
@@ -294,5 +294,49 @@ describe RubyValve::Base do
|
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
297
|
+
describe "#after_exception" do
|
298
|
+
before(:each) do
|
299
|
+
|
300
|
+
class AfterRaise < RubyValve::Base
|
301
|
+
define_method(:after_exception) {}
|
302
|
+
define_method(:step_1) {skip :step_2}
|
303
|
+
define_method(:step_2) {}
|
304
|
+
define_method(:step_3) {abort "Ug", :raise => true}
|
305
|
+
define_method(:step_4) {}
|
306
|
+
define_method(:step_5) {}
|
297
307
|
|
308
|
+
end
|
309
|
+
|
310
|
+
@after_raise = AfterRaise.new
|
311
|
+
end
|
312
|
+
|
313
|
+
it "should not raise AbortError when :raise => true" do
|
314
|
+
expect {@after_raise.execute}.to_not raise_error
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "#exception" do
|
320
|
+
before(:each) do
|
321
|
+
|
322
|
+
class AfterRaise < RubyValve::Base
|
323
|
+
define_method(:after_exception) {}
|
324
|
+
define_method(:step_1) {skip :step_2}
|
325
|
+
define_method(:step_2) {}
|
326
|
+
define_method(:step_3) {abort "Ug", :raise => true}
|
327
|
+
define_method(:step_4) {}
|
328
|
+
define_method(:step_5) {}
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
@after_raise = AfterRaise.new
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should contain the raised exception" do
|
336
|
+
@after_raise.execute
|
337
|
+
@after_raise.exception.should be_a_kind_of(RubyValve::AbortError)
|
338
|
+
@after_raise.exception.message.should eql("Ug")
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
298
342
|
end
|