ruby_valve 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b8f2c19f9c27eb98876a7d17762a72bd3aabe6e
4
- data.tar.gz: c2464b0627d5b46a1258483ebf08de8ebc43af9c
3
+ metadata.gz: f4d50d81c326d8a6f9697ecca411d1c93e55e1b8
4
+ data.tar.gz: 40067d0f4e20b60631aa0a266902163ee18d12f9
5
5
  SHA512:
6
- metadata.gz: 89314afbeab98957cc74e86902ab0a051c7ced0e416a77fbcd6082640e4f56231a9a7f243888fccad362ea2e7934dbba60dea990af0a0b4e0508e8c32dec101a
7
- data.tar.gz: 74242411a418b50dfb041d65fd52ded3d352271820d1ab1ad8de21bea27bdc3b904105c5e8479f8d6864371c45fc6d829709cea25b088fbd969e267a9d4e391b
6
+ metadata.gz: 4e50b22481aad6156bd1a24a706638874cd6a08f255353da7025c9800d7b1a0f1885a82dd2f9c77ec57b36331dcf6975cff28a59465e16a994733137a09a190b
7
+ data.tar.gz: 9daf1e21a4ee2de2e30c256b25d6f74f0a20c52cc3f271e98af945b9f5c6b399e7c45a45d1cc7c2732d48ef05d04bd837aad07605d7aef1d77c4acfa62f53024
data/README.md CHANGED
@@ -21,13 +21,21 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
 
24
- To use RubyValve you need to subclass the base class:
24
+ To use RubyValve you can subclass the base class:
25
25
 
26
26
  require 'ruby_valve'
27
27
 
28
28
  class Foo < RubyValve::Base
29
29
  end
30
30
 
31
+ Or, you can include RubyValve::Core
32
+
33
+ require 'ruby_valve'
34
+
35
+ class Foo
36
+ include RubyValve::Core
37
+
38
+ end
31
39
 
32
40
  ####\#step_n methods
33
41
  Next you define a number steps using the naming convention of #step_n for the method name.
@@ -43,7 +51,7 @@ Next you define a number steps using the naming convention of #step_n for the me
43
51
  end
44
52
  end
45
53
 
46
- After defining #step_n methods you can execute then all by running the #execute method.
54
+ After defining #step_n methods you can execute them all by running the #execute method.
47
55
 
48
56
  Foo.new.execute
49
57
 
@@ -358,4 +366,9 @@ I would recommend encapsulating the logic of what is to be done into methods wit
358
366
 
359
367
  def post_paypal_transaction
360
368
  #code
361
- end
369
+ end
370
+
371
+ ###Tests
372
+ Test are implemented in Rspec and use guard as well.
373
+
374
+ ruby_valve > bundle exec rspec spec
@@ -1,130 +1,8 @@
1
- require 'ruby_valve/errors'
1
+ require 'ruby_valve/core'
2
2
 
3
3
  module RubyValve
4
4
  class Base
5
- attr_reader :executed_steps, :executed, :exception
6
-
7
- def init
8
- @skip_list = []
9
- end
10
-
11
- def execute
12
- init
13
-
14
- if respond_to?(:after_exception)
15
- begin
16
- execute_methods
17
- rescue => e
18
- @exception = e
19
- send(:after_exception)
20
- end
21
- else
22
- execute_methods
23
- end
24
-
25
- end
26
-
27
- def response
28
- @response
29
- end
30
-
31
- protected
32
-
33
- def execute_methods
34
- # begin
35
- @response = {}
36
-
37
- if respond_to?(:before_all)
38
- send(:before_all)
39
- log_execution(:before_all)
40
- end
41
-
42
- execution_order.each do |_method|
43
- if !self.skip?(_method)
44
-
45
- if respond_to?(:before_each)
46
- send(:before_each)
47
- log_execution(:before_each)
48
- end
49
-
50
- #create method to store step results
51
- self.class.class_eval {attr_accessor :"#{_method}_result"}
52
- result = send(_method)
53
-
54
- #assign step result information
55
- @response[:"#{_method}_result"] = result
56
- send(:"#{_method}_result=", result)
57
-
58
- #log step exec
59
- log_step_execution(_method)
60
-
61
- if respond_to?(:after_each)
62
- send(:after_each)
63
- log_execution(:after_each)
64
- end
65
- end
66
- end
67
-
68
- if respond_to?(:after_success) && !abort_triggered?
69
- send(:after_success)
70
- log_execution(:after_success)
71
- end
72
-
73
- if respond_to?(:after_abort) && abort_triggered?
74
- send(:after_abort)
75
- log_execution(:after_abort)
76
- end
77
- end
78
-
79
- #=> logging methods
80
- def log_step_execution(_method)
81
- (@executed_steps ||= []) << _method
82
- log_execution(_method)
83
- end
84
-
85
- def log_execution(_method)
86
- (@executed ||= []) << _method
87
- end
88
-
89
- def abort(message, options = {})
90
- @abort_triggered = true
91
- @abort_message = message
92
- raise(AbortError, @abort_message) if options[:raise]
93
- end
94
-
95
- #=> skip methods
96
- def skip_all_steps?
97
- abort_triggered?
98
- end
99
-
100
- def skip(*step_names)
101
- skip_list.push *step_names
102
- end
103
-
104
- def skip_list
105
- @skip_list
106
- end
107
-
108
- def abort_triggered?
109
- @abort_triggered
110
- end
111
-
112
- def skip?(method_name)
113
- return true if skip_all_steps?
114
-
115
- skip_list.include?(method_name)
116
- end
117
-
118
- def execution_order
119
- step_methods = methods.select {|meth| meth.to_s.match(/^step_[0-9]*$/)}
120
-
121
- step_methods.sort do |x,y|
122
- ordinal_x = x.to_s.split("_").last.to_i
123
- ordinal_y = y.to_s.split("_").last.to_i
124
-
125
- ordinal_x <=> ordinal_y
126
- end
127
- end
5
+ include Core
128
6
 
129
7
  end
130
8
  end
@@ -0,0 +1,129 @@
1
+ require 'ruby_valve/errors'
2
+
3
+ module RubyValve
4
+ module Core
5
+ attr_reader :executed_steps, :executed, :exception
6
+
7
+ def init
8
+ @skip_list = []
9
+ end
10
+
11
+ def execute
12
+ init
13
+
14
+ if respond_to?(:after_exception)
15
+ begin
16
+ execute_methods
17
+ rescue => e
18
+ @exception = e
19
+ send(:after_exception)
20
+ end
21
+ else
22
+ execute_methods
23
+ end
24
+
25
+ end
26
+
27
+ def response
28
+ @response
29
+ end
30
+
31
+ protected
32
+
33
+ def execute_methods
34
+ # begin
35
+ @response = {}
36
+
37
+ if respond_to?(:before_all)
38
+ send(:before_all)
39
+ log_execution(:before_all)
40
+ end
41
+
42
+ execution_order.each do |_method|
43
+ if !self.skip?(_method)
44
+
45
+ if respond_to?(:before_each)
46
+ send(:before_each)
47
+ log_execution(:before_each)
48
+ end
49
+
50
+ #create method to store step results
51
+ self.class.class_eval {attr_accessor :"#{_method}_result"}
52
+ result = send(_method)
53
+
54
+ #assign step result information
55
+ @response[:"#{_method}_result"] = result
56
+ send(:"#{_method}_result=", result)
57
+
58
+ #log step exec
59
+ log_step_execution(_method)
60
+
61
+ if respond_to?(:after_each)
62
+ send(:after_each)
63
+ log_execution(:after_each)
64
+ end
65
+ end
66
+ end
67
+
68
+ if respond_to?(:after_success) && !abort_triggered?
69
+ send(:after_success)
70
+ log_execution(:after_success)
71
+ end
72
+
73
+ if respond_to?(:after_abort) && abort_triggered?
74
+ send(:after_abort)
75
+ log_execution(:after_abort)
76
+ end
77
+ end
78
+
79
+ #=> logging methods
80
+ def log_step_execution(_method)
81
+ (@executed_steps ||= []) << _method
82
+ log_execution(_method)
83
+ end
84
+
85
+ def log_execution(_method)
86
+ (@executed ||= []) << _method
87
+ end
88
+
89
+ def abort(message, options = {})
90
+ @abort_triggered = true
91
+ @abort_message = message
92
+ raise(RubyValve::AbortError, @abort_message) if options[:raise]
93
+ end
94
+
95
+ #=> skip methods
96
+ def skip_all_steps?
97
+ abort_triggered?
98
+ end
99
+
100
+ def skip(*step_names)
101
+ skip_list.push *step_names
102
+ end
103
+
104
+ def skip_list
105
+ @skip_list
106
+ end
107
+
108
+ def abort_triggered?
109
+ @abort_triggered
110
+ end
111
+
112
+ def skip?(method_name)
113
+ return true if skip_all_steps?
114
+
115
+ skip_list.include?(method_name)
116
+ end
117
+
118
+ def execution_order
119
+ step_methods = methods.select {|meth| meth.to_s.match(/^step_[0-9]*$/)}
120
+
121
+ step_methods.sort do |x,y|
122
+ ordinal_x = x.to_s.split("_").last.to_i
123
+ ordinal_y = y.to_s.split("_").last.to_i
124
+
125
+ ordinal_x <=> ordinal_y
126
+ end
127
+ end
128
+ end
129
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyValve
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/ruby_valve.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["necrocommit@gmail.com"]
11
11
  spec.description = %q{This gem provide a mechanism for doing easy flow type code pattern}
12
12
  spec.summary = %q{Programming execution flow control}
13
- spec.homepage = "http://github.com/monochromicorn/ruby_valve#step_n-methods"
13
+ spec.homepage = "http://github.com/monochromicorn/ruby_valve"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1,22 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
- DummyValve = Class.new(RubyValve::Base) do
4
- define_method(:step_1) {}
5
- define_method(:step_2) {}
6
- define_method(:step_3) {}
7
- end
3
+
8
4
 
9
5
  describe RubyValve::Base do
10
- before(:each) do
11
- @valve = DummyValve.new
12
- end
6
+ describe "#execute" do
7
+ before(:each) do
8
+
9
+ class DummyValve
10
+ include RubyValve::Core
11
+
12
+ define_method(:step_1) {}
13
+ define_method(:step_2) {}
14
+ define_method(:step_3) {}
15
+ end
16
+
17
+ @valve = DummyValve.new
18
+ end
19
+
20
+ it "should execute all step methods in order" do
21
+ @valve.execute
22
+ @valve.executed_steps.should eql([:step_1, :step_2, :step_3])
23
+ end
24
+
25
+ it "should not execute steps after an abort" do
26
+ def @valve.step_0
27
+ abort "Ug, I give up"
28
+ end
13
29
 
14
- it "should execute all step methods in order" do
15
- @valve.execute
16
- @valve.executed_steps.should eql([:step_1, :step_2, :step_3])
30
+ @valve.execute
31
+ @valve.executed_steps.should eql([:step_0])
32
+ end
17
33
  end
18
34
 
19
- context "#skip should make it skip a step" do
35
+ describe "#skip" do
20
36
  before(:each) do
21
37
 
22
38
  class SkipValve < RubyValve::Base
@@ -32,12 +48,300 @@ describe RubyValve::Base do
32
48
 
33
49
  it "should not execute skipped steps" do
34
50
  @skip_valve.execute
35
- @skip_valve.executed_steps.should eql([])
51
+ @skip_valve.executed_steps.should eql([:step_1, :step_3])
52
+ end
53
+ end
54
+
55
+ describe "#response" do
56
+ before(:each) do
57
+
58
+ class Res < RubyValve::Base
59
+ define_method(:step_1) {"apple"}
60
+ define_method(:step_2) {"banana"}
61
+ end
62
+
63
+ @res = Res.new
64
+ end
65
+
66
+ it "should contain the method results" do
67
+ @res.execute
68
+ @res.response.should eql({:step_1_result=>"apple", :step_2_result=>"banana"})
69
+ end
70
+ end
71
+
72
+ describe "#step_x_result" do
73
+ before(:each) do
74
+
75
+ class Res1 < RubyValve::Base
76
+ define_method(:step_1) {"apple"}
77
+ define_method(:step_2) {"banana"}
78
+ end
79
+
80
+ @res1 = Res1.new
81
+ end
82
+
83
+ it "should equal the result of #step_x" do
84
+ @res1.execute
85
+ @res1.step_1_result.should eql "apple"
86
+ @res1.step_2_result.should eql "banana"
36
87
  end
37
88
  end
38
- # context ".executed_steps" do
39
- # it "should re"
40
- # end
41
89
 
90
+ describe "#abort" do
91
+ before(:each) do
92
+
93
+ class AfterAbort < RubyValve::Base
94
+ define_method(:after_abort) {}
95
+ define_method(:step_1) {skip :step_2}
96
+ define_method(:step_2) {}
97
+ define_method(:step_3) {abort "Ug", :raise => true}
98
+ define_method(:step_4) {}
99
+ define_method(:step_5) {}
100
+ end
101
+
102
+ @after_abort = AfterAbort.new
103
+ end
104
+
105
+ it "should raise AbortError when :raise => true" do
106
+ expect {@after_abort.execute}.to raise_error(RubyValve::AbortError, "Ug")
107
+ end
108
+ end
109
+
110
+ #==> BEFORE HOOKS
111
+ describe "#before_each" do
112
+ before(:each) do
113
+
114
+ class BeforeEach < RubyValve::Base
115
+ define_method(:before_each) {}
116
+ define_method(:step_1) {skip :step_2}
117
+ define_method(:step_2) {}
118
+ define_method(:step_3) {skip :step_4, :step_5}
119
+ define_method(:step_4) {}
120
+ define_method(:step_5) {}
121
+ end
122
+
123
+ @before_each = BeforeEach.new
124
+ end
125
+
126
+ it "should execute when defined" do
127
+ @before_each.should_receive(:before_each).exactly(2)
128
+ @before_each.execute
129
+ end
130
+
131
+ it "should execute before each step_x" do
132
+ @before_each.execute
133
+ @before_each.executed.should eql([:before_each, :step_1, :before_each, :step_3])
134
+ end
135
+
136
+ it "should not show up in executed_steps" do
137
+ @before_each.execute
138
+ @before_each.executed_steps.should eql([:step_1, :step_3])
139
+ end
140
+
141
+ end
142
+
143
+ describe "#before_all" do
144
+ before(:each) do
145
+
146
+ class BeforeAll < RubyValve::Base
147
+ define_method(:before_all) {}
148
+ define_method(:step_1) {skip :step_2}
149
+ define_method(:step_2) {}
150
+ define_method(:step_3) {skip :step_4, :step_5}
151
+ define_method(:step_4) {}
152
+ define_method(:step_5) {}
153
+ end
154
+
155
+ @before_all = BeforeAll.new
156
+ end
157
+
158
+ it "should execute when defined" do
159
+ @before_all.should_receive(:before_all).exactly(1)
160
+ @before_all.execute
161
+ end
162
+
163
+ it "should execute before all steps" do
164
+ @before_all.execute
165
+ @before_all.executed.should eql([:before_all, :step_1, :step_3])
166
+ end
167
+
168
+ it "should not show up in executed_steps" do
169
+ @before_all.execute
170
+ @before_all.executed_steps.should eql([:step_1, :step_3])
171
+ end
172
+
173
+ end
174
+
175
+ #==> AFTER HOOKS
176
+ describe "#after_each" do
177
+ before(:each) do
178
+
179
+ class AfterEach < RubyValve::Base
180
+ define_method(:after_each) {}
181
+ define_method(:step_1) {skip :step_2}
182
+ define_method(:step_2) {}
183
+ define_method(:step_3) {skip :step_4, :step_5}
184
+ define_method(:step_4) {}
185
+ define_method(:step_5) {}
186
+ end
187
+
188
+ @after_each = AfterEach.new
189
+ end
190
+
191
+ it "should execute when defined" do
192
+ @after_each.should_receive(:after_each).exactly(2)
193
+ @after_each.execute
194
+ end
195
+
196
+ it "should execute after each step_x" do
197
+ @after_each.execute
198
+ @after_each.executed.should eql([:step_1, :after_each, :step_3, :after_each])
199
+ end
200
+
201
+ it "should not show up in executed_steps" do
202
+ @after_each.execute
203
+ @after_each.executed_steps.should eql([:step_1, :step_3])
204
+ end
205
+
206
+ end
207
+
208
+ describe "#after_success" do
209
+ before(:each) do
210
+
211
+ class AfterSuccess < RubyValve::Base
212
+ define_method(:after_success) {}
213
+ define_method(:step_1) {skip :step_2}
214
+ define_method(:step_2) {}
215
+ define_method(:step_3) {skip :step_4, :step_5}
216
+ define_method(:step_4) {}
217
+ define_method(:step_5) {}
218
+ end
219
+
220
+ @after_success = AfterSuccess.new
221
+ end
222
+
223
+ context "when no abort is triggered" do
224
+
225
+ it "should execute when defined" do
226
+ @after_success.should_receive(:after_success).exactly(1)
227
+ @after_success.execute
228
+ end
229
+
230
+ it "should execute after all steps" do
231
+ @after_success.execute
232
+ @after_success.executed.should eql([:step_1, :step_3, :after_success])
233
+ end
234
+
235
+ it "should not execute after an abort" do
236
+ def @after_success.step_1
237
+ abort "Ug"
238
+ end
239
+
240
+ @after_success.execute
241
+ @after_success.executed.should eql([:step_1])
242
+ end
243
+
244
+ it "should not show up in executed_steps" do
245
+ @after_success.execute
246
+ @after_success.executed_steps.should eql([:step_1, :step_3])
247
+ end
248
+
249
+ end
250
+
251
+ context "when an abort is triggered" do
252
+ it "should not execute when defined" do
253
+ def @after_success.step_1
254
+ abort "Ug"
255
+ end
256
+
257
+ @after_success.should_receive(:after_success).exactly(0)
258
+ @after_success.execute
259
+ end
260
+ end
261
+ end
262
+
263
+ describe "#after_abort" do
264
+ context "after an abort is triggered" do
265
+ before(:each) do
266
+
267
+ class AfterAbort < RubyValve::Base
268
+ define_method(:after_abort) {}
269
+ define_method(:step_1) {skip :step_2}
270
+ define_method(:step_2) {}
271
+ define_method(:step_3) {abort "Ug"}
272
+ define_method(:step_4) {}
273
+ define_method(:step_5) {}
274
+ end
275
+
276
+ @after_abort = AfterAbort.new
277
+ end
278
+
279
+ it "should execute when defined" do
280
+ @after_abort.should_receive(:after_abort).exactly(1)
281
+ @after_abort.execute
282
+ end
283
+
284
+ it "should execute after all the steps" do
285
+ @after_abort.execute
286
+ @after_abort.executed.should eql([:step_1, :step_3, :after_abort])
287
+ end
288
+
289
+ it "should not execute steps after an abort" do
290
+ @after_abort.execute
291
+ @after_abort.executed_steps.should eql([:step_1, :step_3])
292
+ end
293
+
294
+ it "should not show up in executed_steps" do
295
+ @after_abort.execute
296
+ @after_abort.executed_steps.should eql([:step_1, :step_3])
297
+ end
298
+
299
+ end
300
+ end
301
+
302
+ describe "#after_exception" do
303
+ before(:each) do
304
+
305
+ class AfterRaise < RubyValve::Base
306
+ define_method(:after_exception) {}
307
+ define_method(:step_1) {skip :step_2}
308
+ define_method(:step_2) {}
309
+ define_method(:step_3) {abort "Ug", :raise => true}
310
+ define_method(:step_4) {}
311
+ define_method(:step_5) {}
312
+
313
+ end
314
+
315
+ @after_raise = AfterRaise.new
316
+ end
317
+
318
+ it "should not raise AbortError when :raise => true" do
319
+ expect {@after_raise.execute}.to_not raise_error
320
+ end
321
+
322
+ end
323
+
324
+ describe "#exception" do
325
+ before(:each) do
326
+
327
+ class AfterRaise < RubyValve::Base
328
+ define_method(:after_exception) {}
329
+ define_method(:step_1) {skip :step_2}
330
+ define_method(:step_2) {}
331
+ define_method(:step_3) {abort "Ug", :raise => true}
332
+ define_method(:step_4) {}
333
+ define_method(:step_5) {}
334
+
335
+ end
336
+
337
+ @after_raise = AfterRaise.new
338
+ end
339
+
340
+ it "should contain the raised exception" do
341
+ @after_raise.execute
342
+ @after_raise.exception.should be_a_kind_of(RubyValve::AbortError)
343
+ @after_raise.exception.message.should eql("Ug")
344
+ end
42
345
 
346
+ end
43
347
  end
@@ -1,14 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
- DummyValve = Class.new(RubyValve::Base) do
4
- define_method(:step_1) {}
5
- define_method(:step_2) {}
6
- define_method(:step_3) {}
7
- end
8
-
9
3
  describe RubyValve::Base do
10
4
  describe "#execute" do
11
5
  before(:each) do
6
+ class DummyValve
7
+ include RubyValve::Core
8
+ define_method(:step_1) {}
9
+ define_method(:step_2) {}
10
+ define_method(:step_3) {}
11
+ end
12
+
12
13
  @valve = DummyValve.new
13
14
  end
14
15
 
@@ -30,7 +31,8 @@ describe RubyValve::Base do
30
31
  describe "#skip" do
31
32
  before(:each) do
32
33
 
33
- class SkipValve < RubyValve::Base
34
+ class SkipValve
35
+ include RubyValve::Core
34
36
  define_method(:step_1) {skip :step_2}
35
37
  define_method(:step_2) {}
36
38
  define_method(:step_3) {skip :step_4, :step_5}
@@ -50,7 +52,9 @@ describe RubyValve::Base do
50
52
  describe "#response" do
51
53
  before(:each) do
52
54
 
53
- class Res < RubyValve::Base
55
+ class Res
56
+ include RubyValve::Core
57
+
54
58
  define_method(:step_1) {"apple"}
55
59
  define_method(:step_2) {"banana"}
56
60
  end
@@ -67,7 +71,9 @@ describe RubyValve::Base do
67
71
  describe "#step_x_result" do
68
72
  before(:each) do
69
73
 
70
- class Res1 < RubyValve::Base
74
+ class Res1
75
+ include RubyValve::Core
76
+
71
77
  define_method(:step_1) {"apple"}
72
78
  define_method(:step_2) {"banana"}
73
79
  end
@@ -85,7 +91,9 @@ describe RubyValve::Base do
85
91
  describe "#abort" do
86
92
  before(:each) do
87
93
 
88
- class AfterAbort < RubyValve::Base
94
+ class AfterAbort
95
+ include RubyValve::Core
96
+
89
97
  define_method(:after_abort) {}
90
98
  define_method(:step_1) {skip :step_2}
91
99
  define_method(:step_2) {}
@@ -106,7 +114,9 @@ describe RubyValve::Base do
106
114
  describe "#before_each" do
107
115
  before(:each) do
108
116
 
109
- class BeforeEach < RubyValve::Base
117
+ class BeforeEach
118
+ include RubyValve::Core
119
+
110
120
  define_method(:before_each) {}
111
121
  define_method(:step_1) {skip :step_2}
112
122
  define_method(:step_2) {}
@@ -138,7 +148,8 @@ describe RubyValve::Base do
138
148
  describe "#before_all" do
139
149
  before(:each) do
140
150
 
141
- class BeforeAll < RubyValve::Base
151
+ class BeforeAll
152
+ include RubyValve::Core
142
153
  define_method(:before_all) {}
143
154
  define_method(:step_1) {skip :step_2}
144
155
  define_method(:step_2) {}
@@ -171,7 +182,9 @@ describe RubyValve::Base do
171
182
  describe "#after_each" do
172
183
  before(:each) do
173
184
 
174
- class AfterEach < RubyValve::Base
185
+ class AfterEach
186
+ include RubyValve::Core
187
+
175
188
  define_method(:after_each) {}
176
189
  define_method(:step_1) {skip :step_2}
177
190
  define_method(:step_2) {}
@@ -203,7 +216,9 @@ describe RubyValve::Base do
203
216
  describe "#after_success" do
204
217
  before(:each) do
205
218
 
206
- class AfterSuccess < RubyValve::Base
219
+ class AfterSuccess
220
+ include RubyValve::Core
221
+
207
222
  define_method(:after_success) {}
208
223
  define_method(:step_1) {skip :step_2}
209
224
  define_method(:step_2) {}
@@ -259,7 +274,9 @@ describe RubyValve::Base do
259
274
  context "after an abort is triggered" do
260
275
  before(:each) do
261
276
 
262
- class AfterAbort < RubyValve::Base
277
+ class AfterAbortTest
278
+ include RubyValve::Core
279
+
263
280
  define_method(:after_abort) {}
264
281
  define_method(:step_1) {skip :step_2}
265
282
  define_method(:step_2) {}
@@ -268,7 +285,7 @@ describe RubyValve::Base do
268
285
  define_method(:step_5) {}
269
286
  end
270
287
 
271
- @after_abort = AfterAbort.new
288
+ @after_abort = AfterAbortTest.new
272
289
  end
273
290
 
274
291
  it "should execute when defined" do
@@ -297,7 +314,9 @@ describe RubyValve::Base do
297
314
  describe "#after_exception" do
298
315
  before(:each) do
299
316
 
300
- class AfterRaise < RubyValve::Base
317
+ class AfterRaise
318
+ include RubyValve::Core
319
+
301
320
  define_method(:after_exception) {}
302
321
  define_method(:step_1) {skip :step_2}
303
322
  define_method(:step_2) {}
@@ -319,7 +338,9 @@ describe RubyValve::Base do
319
338
  describe "#exception" do
320
339
  before(:each) do
321
340
 
322
- class AfterRaise < RubyValve::Base
341
+ class ExceptionTest
342
+ include RubyValve::Core
343
+
323
344
  define_method(:after_exception) {}
324
345
  define_method(:step_1) {skip :step_2}
325
346
  define_method(:step_2) {}
@@ -329,7 +350,7 @@ describe RubyValve::Base do
329
350
 
330
351
  end
331
352
 
332
- @after_raise = AfterRaise.new
353
+ @after_raise = ExceptionTest.new
333
354
  end
334
355
 
335
356
  it "should contain the raised exception" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_valve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - monochromicorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,13 +96,14 @@ files:
96
96
  - Rakefile
97
97
  - lib/ruby_valve.rb
98
98
  - lib/ruby_valve/base.rb
99
+ - lib/ruby_valve/core.rb
99
100
  - lib/ruby_valve/errors.rb
100
101
  - lib/ruby_valve/version.rb
101
102
  - ruby_valve.gemspec
102
- - spec/lib/base_spec.rb
103
103
  - spec/lib/ruby_valve/base_spec.rb
104
+ - spec/lib/ruby_valve/core_spec.rb
104
105
  - spec/spec_helper.rb
105
- homepage: http://github.com/monochromicorn/ruby_valve#step_n-methods
106
+ homepage: http://github.com/monochromicorn/ruby_valve
106
107
  licenses:
107
108
  - MIT
108
109
  metadata: {}
@@ -127,7 +128,7 @@ signing_key:
127
128
  specification_version: 4
128
129
  summary: Programming execution flow control
129
130
  test_files:
130
- - spec/lib/base_spec.rb
131
131
  - spec/lib/ruby_valve/base_spec.rb
132
+ - spec/lib/ruby_valve/core_spec.rb
132
133
  - spec/spec_helper.rb
133
134
  has_rdoc: