rbehave 0.2.0 → 0.2.1
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.
- data/Manifest.txt +2 -0
- data/behaviour/examples/builders.rb +44 -0
- data/behaviour/examples/helper.rb +1 -0
- data/behaviour/examples/rbehave/documenter/plain_text_documenter_behaviour.rb +2 -1
- data/behaviour/examples/rbehave/given_scenario_behaviour.rb +3 -3
- data/behaviour/examples/rbehave/reporter/plain_text_reporter_behaviour.rb +1 -1
- data/behaviour/examples/rbehave/runner/options_behaviour.rb +13 -3
- data/behaviour/examples/rbehave/runner/runner_behaviour.rb +5 -4
- data/behaviour/examples/rbehave/runner/scenario_runner_behaviour.rb +9 -2
- data/behaviour/examples/rbehave/runner/story_runner_behaviour.rb +3 -3
- data/behaviour/examples/rbehave/scenario_behaviour.rb +18 -0
- data/behaviour/examples/rbehave/story_behaviour.rb +10 -0
- data/behaviour/examples/rbehave/world_behaviour.rb +54 -28
- data/examples/game-of-life/README.txt +5 -5
- data/examples/game-of-life/behaviour/examples/game_behaviour.rb +1 -4
- data/examples/game-of-life/behaviour/examples/grid_behaviour.rb +1 -1
- data/examples/game-of-life/behaviour/stories/ICanCreateACell.story +1 -1
- data/examples/game-of-life/behaviour/stories/create_a_cell.rb +2 -2
- data/examples/game-of-life/life/grid.rb +5 -4
- data/lib/rbehave/documenter/plain_text_documenter.rb +2 -1
- data/lib/rbehave/exceptions.rb +1 -2
- data/lib/rbehave/given_scenario.rb +1 -1
- data/lib/rbehave/reporter/plain_text_reporter.rb +4 -0
- data/lib/rbehave/runner.rb +6 -10
- data/lib/rbehave/runner/options.rb +4 -1
- data/lib/rbehave/runner/story_runner.rb +3 -1
- data/lib/rbehave/scenario.rb +1 -0
- data/lib/rbehave/simple_step.rb +7 -0
- data/lib/rbehave/story.rb +7 -1
- data/lib/rbehave/version.rb +1 -1
- data/lib/rbehave/world.rb +17 -5
- metadata +4 -2
data/Manifest.txt
CHANGED
@@ -31,6 +31,8 @@ behaviour/examples/rbehave/reporter/plain_text_reporter_behaviour.rb
|
|
31
31
|
behaviour/examples/rbehave/step_mother_behaviour.rb
|
32
32
|
behaviour/examples/rbehave/documenter/plain_text_documenter_behaviour.rb
|
33
33
|
behaviour/examples/rbehave/simple_step_behaviour.rb
|
34
|
+
behaviour/examples/rbehave/scenario_behaviour.rb
|
35
|
+
behaviour/examples/builders.rb
|
34
36
|
examples/game-of-life/life/game.rb
|
35
37
|
examples/game-of-life/life/grid.rb
|
36
38
|
examples/game-of-life/.loadpath
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module RBehave
|
2
|
+
class StoryBuilder
|
3
|
+
def initialize
|
4
|
+
@title = 'a story'
|
5
|
+
@narrative = 'narrative'
|
6
|
+
end
|
7
|
+
|
8
|
+
def title(value)
|
9
|
+
@title = value
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def narrative(value)
|
14
|
+
@narrative = value
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_story(&block)
|
19
|
+
block = lambda {} unless block_given?
|
20
|
+
Story.new @title, @narrative, &block
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ScenarioBuilder
|
25
|
+
def initialize
|
26
|
+
@name = 'a scenario'
|
27
|
+
@story = StoryBuilder.new.to_story
|
28
|
+
end
|
29
|
+
|
30
|
+
def name(value)
|
31
|
+
@name = value
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def story(value)
|
36
|
+
@story = value
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_scenario(&block)
|
41
|
+
Scenario.new @story, @name, &block
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'behaviour/examples/helper'
|
2
|
+
require 'spec'
|
2
3
|
|
3
4
|
module RBehave
|
4
5
|
describe GivenScenario do
|
@@ -8,11 +9,10 @@ module RBehave
|
|
8
9
|
attr :scenario_ran
|
9
10
|
end
|
10
11
|
instance = MyWorld.new
|
11
|
-
|
12
|
-
scenario = Scenario.new story, 'scenario name' do
|
12
|
+
scenario = ScenarioBuilder.new.to_scenario do
|
13
13
|
@scenario_ran = true
|
14
14
|
end
|
15
|
-
Runner::StoryRunner.
|
15
|
+
Runner::StoryRunner.stubs(:scenario_from_current_story).with('scenario name').returns(scenario)
|
16
16
|
|
17
17
|
step = GivenScenario.new 'scenario name'
|
18
18
|
|
@@ -3,11 +3,14 @@ require 'behaviour/examples/helper'
|
|
3
3
|
module RBehave
|
4
4
|
module Runner
|
5
5
|
describe Options do
|
6
|
-
|
6
|
+
before :each do
|
7
7
|
@options = Options.new
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should parse -n as dry run' do
|
11
|
+
# given
|
12
|
+
@options.dry_run.nil?
|
13
|
+
|
11
14
|
# when
|
12
15
|
@options.parse %w[ -n ]
|
13
16
|
# then
|
@@ -21,19 +24,26 @@ module RBehave
|
|
21
24
|
ensure_that @options.dry_run, is(true)
|
22
25
|
end
|
23
26
|
|
24
|
-
it 'should parse
|
27
|
+
it 'should parse -f fmt as format' do
|
25
28
|
# when
|
26
29
|
@options.parse %w[ -f s ]
|
27
30
|
# then
|
28
31
|
ensure_that @options.format, is(:simple)
|
29
32
|
end
|
30
33
|
|
31
|
-
it 'should parse
|
34
|
+
it 'should parse --format fmt as format' do
|
32
35
|
# when
|
33
36
|
@options.parse %w[ --format h ]
|
34
37
|
# then
|
35
38
|
ensure_that @options.format, is(:html)
|
36
39
|
end
|
40
|
+
|
41
|
+
it 'should parse --debug' do
|
42
|
+
# when
|
43
|
+
@options.parse %w[ --debug ]
|
44
|
+
# then
|
45
|
+
ensure_that @options.debug, is(true)
|
46
|
+
end
|
37
47
|
end
|
38
48
|
end
|
39
49
|
end
|
@@ -10,14 +10,16 @@ module RBehave
|
|
10
10
|
return io
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
before :each do
|
14
14
|
@stdout, $stdout = $stdout, dev_null
|
15
15
|
@argv = Array.new(ARGV)
|
16
|
+
Runner.module_eval { @options = nil }
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
after :each do
|
19
20
|
$stdout = @stdout
|
20
|
-
ARGV.
|
21
|
+
ARGV.replace @argv
|
22
|
+
Runner.module_eval { @options = nil }
|
21
23
|
end
|
22
24
|
|
23
25
|
it 'should wire up a singleton StoryRunner' do
|
@@ -26,7 +28,6 @@ module RBehave
|
|
26
28
|
|
27
29
|
it 'should set its options based on ARGV' do
|
28
30
|
# given
|
29
|
-
Runner.module_eval { @options = nil }
|
30
31
|
ARGV << '--dry-run'
|
31
32
|
|
32
33
|
# when
|
@@ -3,6 +3,14 @@ require 'behaviour/examples/helper'
|
|
3
3
|
module RBehave
|
4
4
|
module Runner
|
5
5
|
describe ScenarioRunner do
|
6
|
+
before do
|
7
|
+
mocha_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
mocha_teardown
|
12
|
+
end
|
13
|
+
|
6
14
|
it 'should run a scenario in its story' do
|
7
15
|
# given
|
8
16
|
world = stub_everything
|
@@ -117,8 +125,7 @@ module RBehave
|
|
117
125
|
verify_mocks
|
118
126
|
end
|
119
127
|
|
120
|
-
|
121
|
-
it 'should notify listeners when a scenario raises an error' do
|
128
|
+
it 'should notify listeners when a scenario is pending' do
|
122
129
|
# given
|
123
130
|
story = Story.new 'title', 'narrative' do end
|
124
131
|
scenario = Scenario.new story, 'scenario1' do
|
@@ -197,18 +197,18 @@ module RBehave
|
|
197
197
|
scenario_world_catcher.worlds[0].size.should == 3
|
198
198
|
end
|
199
199
|
|
200
|
-
it 'should store the current running story' do
|
200
|
+
it 'should store the current running story in the world' do
|
201
201
|
# given
|
202
202
|
$stories = []
|
203
203
|
story_runner = StoryRunner.new(ScenarioRunner.new)
|
204
204
|
story_runner.Story 'title1', 'narrative1' do
|
205
205
|
Scenario 'scenario1' do
|
206
|
-
$stories <<
|
206
|
+
$stories << @current_story
|
207
207
|
end
|
208
208
|
end
|
209
209
|
story_runner.Story 'title2', 'narrative2' do
|
210
210
|
Scenario 'scenario2' do
|
211
|
-
$stories <<
|
211
|
+
$stories << @current_story
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'behaviour/examples/helper'
|
2
|
+
|
3
|
+
module RBehave
|
4
|
+
describe Scenario do
|
5
|
+
it 'should fail to construct if no body is supplied' do
|
6
|
+
# given
|
7
|
+
story = StoryBuilder.new.to_story
|
8
|
+
|
9
|
+
# when
|
10
|
+
error = exception_from do
|
11
|
+
Scenario.new story, 'name'
|
12
|
+
end
|
13
|
+
|
14
|
+
# then
|
15
|
+
error.should be_kind_of(ArgumentError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -16,5 +16,15 @@ module RBehave
|
|
16
16
|
# then
|
17
17
|
$instance.should be(object)
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'should raise an error if no block is supplied' do
|
21
|
+
# when
|
22
|
+
error = exception_from do
|
23
|
+
Story.new 'title', 'narrative'
|
24
|
+
end
|
25
|
+
|
26
|
+
# then
|
27
|
+
error.should be_kind_of(ArgumentError)
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
@@ -2,14 +2,14 @@ require 'behaviour/examples/helper'
|
|
2
2
|
|
3
3
|
module RBehave
|
4
4
|
describe World do
|
5
|
-
|
5
|
+
before :each do
|
6
|
+
mocha_setup
|
6
7
|
World.listeners.clear
|
7
|
-
RBehave::Runner.dry_run = false
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
after :each do
|
11
11
|
World.listeners.clear
|
12
|
-
|
12
|
+
mocha_teardown
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should create an object that mixes in a World' do
|
@@ -31,12 +31,7 @@ module RBehave
|
|
31
31
|
|
32
32
|
it 'should pass arguments to #new when creating an object of a specified type that mixes in a world' do
|
33
33
|
# given
|
34
|
-
|
35
|
-
attr_reader :name, :age
|
36
|
-
def initialize(name, age)
|
37
|
-
@name, @age = name, age
|
38
|
-
end
|
39
|
-
end
|
34
|
+
Thing = Struct.new(:name, :age)
|
40
35
|
|
41
36
|
# when
|
42
37
|
obj = World::create Thing, "David", "I'm not telling"
|
@@ -170,6 +165,7 @@ module RBehave
|
|
170
165
|
it 'should invoke a reused step in the new object instance' do
|
171
166
|
# given
|
172
167
|
$instances = []
|
168
|
+
$debug = true
|
173
169
|
world1 = World.create
|
174
170
|
world1.instance_eval do
|
175
171
|
Given 'a given' do
|
@@ -182,10 +178,10 @@ module RBehave
|
|
182
178
|
world2.instance_eval do
|
183
179
|
Given 'a given' # reused
|
184
180
|
Then 'an outcome' do
|
185
|
-
$instances <<
|
181
|
+
$instances << __id__
|
186
182
|
end
|
187
183
|
end
|
188
|
-
|
184
|
+
$debug = false
|
189
185
|
# then
|
190
186
|
$instances.should == [ world1.__id__, world2.__id__, world2.__id__ ]
|
191
187
|
end
|
@@ -254,7 +250,7 @@ module RBehave
|
|
254
250
|
|
255
251
|
it 'should tell listeners but not execute the step in dry-run mode' do
|
256
252
|
# given
|
257
|
-
RBehave::Runner.dry_run
|
253
|
+
RBehave::Runner.stubs(:dry_run).returns(true)
|
258
254
|
mock_listener = mock('listener')
|
259
255
|
World.add_listener(mock_listener)
|
260
256
|
$step_invoked = false
|
@@ -276,23 +272,53 @@ module RBehave
|
|
276
272
|
end
|
277
273
|
|
278
274
|
it 'should ignore pending() calls in dry-run mode' do
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
pending 'todo'
|
288
|
-
end
|
275
|
+
# given
|
276
|
+
world = World.create
|
277
|
+
RBehave::Runner.stubs(:dry_run).returns(true)
|
278
|
+
|
279
|
+
# when
|
280
|
+
ex = exception_from do
|
281
|
+
world.instance_eval do
|
282
|
+
pending 'todo'
|
289
283
|
end
|
290
|
-
|
291
|
-
# then
|
292
|
-
ex.should be_nil
|
293
|
-
ensure
|
294
|
-
RBehave::Runner::dry_run = false
|
295
284
|
end
|
285
|
+
|
286
|
+
# then
|
287
|
+
ex.should be_nil
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'should suppress listeners while it runs a GivenScenario' do
|
291
|
+
# given
|
292
|
+
$scenario_ran = false
|
293
|
+
|
294
|
+
scenario = ScenarioBuilder.new.name('a scenario').to_scenario do
|
295
|
+
$scenario_ran = true
|
296
|
+
Given 'given' do end
|
297
|
+
When 'event' do end
|
298
|
+
Then 'outcome' do end
|
299
|
+
end
|
300
|
+
|
301
|
+
given_scenario = GivenScenario.new('a scenario')
|
302
|
+
|
303
|
+
world = World.create
|
304
|
+
listener = mock('listener')
|
305
|
+
World.add_listener(listener)
|
306
|
+
|
307
|
+
Runner::StoryRunner.stubs(:scenario_from_current_story).
|
308
|
+
with('a scenario').returns(scenario)
|
309
|
+
|
310
|
+
# expect
|
311
|
+
listener.expects(:found_step).with(:'given scenario', 'a scenario')
|
312
|
+
listener.expects(:found_step).never.with(:given, 'given')
|
313
|
+
listener.expects(:found_step).never.with(:when, 'event')
|
314
|
+
listener.expects(:found_step).never.with(:then, 'outcome')
|
315
|
+
|
316
|
+
# when
|
317
|
+
world.GivenScenario 'a scenario'
|
318
|
+
|
319
|
+
# then
|
320
|
+
verify_mocks
|
321
|
+
$scenario_ran.should == true
|
296
322
|
end
|
297
323
|
end
|
298
324
|
end
|
@@ -7,15 +7,15 @@ The game is played on a field of cells, each of which has eight neighbors (adjac
|
|
7
7
|
A cell is either occupied (by an organism) or not.
|
8
8
|
The rules for deriving a generation from the previous one are these:
|
9
9
|
|
10
|
+
Survival
|
11
|
+
--------
|
12
|
+
If an occupied cell has 2 or 3 neighbors, the organism survives to the next generation.
|
13
|
+
|
10
14
|
Death
|
11
15
|
-----
|
12
16
|
If an occupied cell has 0, 1, 4, 5, 6, 7, or 8 occupied neighbors, the organism dies
|
13
17
|
(0, 1: of loneliness; 4 thru 8: of overcrowding).
|
14
18
|
|
15
|
-
Survival
|
16
|
-
--------
|
17
|
-
If an occupied cell has two or three neighbors, the organism survives to the next generation.
|
18
|
-
|
19
19
|
Birth
|
20
20
|
-----
|
21
|
-
If an unoccupied cell has
|
21
|
+
If an unoccupied cell has 3 occupied neighbors, it becomes occupied.
|
@@ -23,13 +23,14 @@ class Grid
|
|
23
23
|
@contents[row][col] = 1
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.
|
26
|
+
def self.from_string(str)
|
27
27
|
row_strings = str.split
|
28
28
|
grid = Grid.new(row_strings.size, row_strings[0].size)
|
29
29
|
|
30
|
-
row_strings.each_with_index do |row,
|
31
|
-
row.split(//)
|
32
|
-
|
30
|
+
row_strings.each_with_index do |row, row_index|
|
31
|
+
row_chars = row.split(//)
|
32
|
+
row_chars.each_with_index do |col_char, col_index|
|
33
|
+
grid.create_at(row_index, col_index) if col_char == 'X'
|
33
34
|
end
|
34
35
|
end
|
35
36
|
return grid
|
@@ -18,7 +18,8 @@ module RBehave
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def found_step(name, description, *args)
|
21
|
-
|
21
|
+
args_txt = args.empty? ? "" : " #{args.join ','}"
|
22
|
+
@out << " #{name.to_s.capitalize} #{description}#{args_txt}\n"
|
22
23
|
end
|
23
24
|
|
24
25
|
def method_missing(meth, *args, &block)
|
data/lib/rbehave/exceptions.rb
CHANGED
@@ -14,8 +14,7 @@ class Exception
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def filtered_backtrace
|
17
|
-
|
18
|
-
trace.reject do |line|
|
17
|
+
backtrace.reject do |line|
|
19
18
|
Exception.backtrace_filters.inject(false) do |already_matched, filter|
|
20
19
|
already_matched || line =~ filter
|
21
20
|
end
|
@@ -8,6 +8,10 @@ module RBehave
|
|
8
8
|
@pending = []
|
9
9
|
end
|
10
10
|
|
11
|
+
def scenario_started(story_title, scenario_name)
|
12
|
+
@out << "#{scenario_name} (#{story_title})\n" if RBehave::Runner.options.debug
|
13
|
+
end
|
14
|
+
|
11
15
|
def scenario_succeeded(story_title, scenario_name)
|
12
16
|
@out << '.'
|
13
17
|
@succeeded += 1
|
data/lib/rbehave/runner.rb
CHANGED
@@ -17,9 +17,9 @@ module RBehave
|
|
17
17
|
@story_runner.add_listener(reporter)
|
18
18
|
end
|
19
19
|
case options.format
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
when :simple then documenter = RBehave::Documenter::PlainTextDocumenter.new($stdout)
|
21
|
+
when nil ;
|
22
|
+
else raise "Unimplemented format - #{options.format.to_s}"
|
23
23
|
end
|
24
24
|
if documenter
|
25
25
|
scenario_runner.add_listener(documenter)
|
@@ -40,13 +40,9 @@ module RBehave
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def dry_run
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def dry_run=(value)
|
48
|
-
@dry_run = value
|
43
|
+
def dry_run
|
44
|
+
options.dry_run
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
52
|
-
end
|
48
|
+
end
|
@@ -3,7 +3,7 @@ require 'optparse'
|
|
3
3
|
module RBehave
|
4
4
|
module Runner
|
5
5
|
class Options
|
6
|
-
|
6
|
+
attr_reader :format, :dry_run, :debug
|
7
7
|
|
8
8
|
def parse(args)
|
9
9
|
parser = OptionParser.new do |p|
|
@@ -17,6 +17,9 @@ module RBehave
|
|
17
17
|
p.on "-f", "--format ", formats, "format (#{formats.join(',')})" do |fmt|
|
18
18
|
@format = fmt.to_sym
|
19
19
|
end
|
20
|
+
p.on '--debug' do
|
21
|
+
@debug = true
|
22
|
+
end
|
20
23
|
end
|
21
24
|
parser.parse(args)
|
22
25
|
self
|
@@ -46,7 +46,9 @@ module RBehave
|
|
46
46
|
scenarios.each do |scenario|
|
47
47
|
type = story[:type] || Object
|
48
48
|
args = story[:args] || []
|
49
|
-
|
49
|
+
world = @world_creator.create(type, *args)
|
50
|
+
world.instance_variable_set :@current_story, story
|
51
|
+
@scenario_runner.run(scenario, world)
|
50
52
|
end
|
51
53
|
@listeners.each { |l| l.story_ended(story.title, story.narrative) }
|
52
54
|
end
|
data/lib/rbehave/scenario.rb
CHANGED
data/lib/rbehave/simple_step.rb
CHANGED
@@ -2,6 +2,7 @@ module RBehave
|
|
2
2
|
class SimpleStep
|
3
3
|
def initialize(name, &block)
|
4
4
|
@name = name
|
5
|
+
# @block = block
|
5
6
|
@mod = Module.new
|
6
7
|
@mod.__send__(:define_method, @name, &block)
|
7
8
|
end
|
@@ -9,6 +10,12 @@ module RBehave
|
|
9
10
|
def perform(instance, *args)
|
10
11
|
instance.extend(@mod)
|
11
12
|
instance.__send__(@name, *args)
|
13
|
+
# block = @block
|
14
|
+
# instance.instance_eval do
|
15
|
+
# puts __id__ if $debug
|
16
|
+
# block.call(*args)
|
17
|
+
# end
|
12
18
|
end
|
19
|
+
|
13
20
|
end
|
14
21
|
end
|
data/lib/rbehave/story.rb
CHANGED
@@ -3,6 +3,7 @@ module RBehave
|
|
3
3
|
attr_reader :title, :narrative
|
4
4
|
|
5
5
|
def initialize(title, narrative, params = {}, &body)
|
6
|
+
raise(ArgumentError, 'A story needs a body') unless block_given?
|
6
7
|
@body = body
|
7
8
|
@title = title
|
8
9
|
@narrative = narrative
|
@@ -14,7 +15,12 @@ module RBehave
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def run_in(obj)
|
17
|
-
|
18
|
+
begin
|
19
|
+
obj.instance_eval(&@body)
|
20
|
+
rescue Exception => e
|
21
|
+
p e
|
22
|
+
raise
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/rbehave/version.rb
CHANGED
data/lib/rbehave/world.rb
CHANGED
@@ -28,20 +28,32 @@ module RBehave
|
|
28
28
|
@step_mother ||= StepMother.new
|
29
29
|
end
|
30
30
|
|
31
|
+
# TODO: lots of duplication between #run_with_suspended_listeners and #store_and_call
|
32
|
+
|
33
|
+
def run_with_suspended_listeners(instance, type, name, step)
|
34
|
+
current_listeners = Array.new(@listeners)
|
35
|
+
begin
|
36
|
+
listeners.each { |l| l.found_step(type, name) }
|
37
|
+
@listeners.clear
|
38
|
+
step.perform(instance) unless RBehave::Runner.dry_run
|
39
|
+
ensure
|
40
|
+
@listeners.replace(current_listeners)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
31
44
|
def store_and_call(instance, type, name, *args, &block)
|
32
45
|
if block_given?
|
33
46
|
step_mother.store(type, name, SimpleStep.new(name, &block))
|
34
47
|
end
|
35
48
|
step = step_mother.find(type, name)
|
36
49
|
listeners.each { |l| l.found_step(type, name, *args) }
|
37
|
-
step.perform(instance, *args) unless RBehave::Runner.dry_run
|
50
|
+
step.perform(instance, *args) unless RBehave::Runner.dry_run
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
41
54
|
def GivenScenario(name)
|
42
|
-
|
43
|
-
|
44
|
-
World.store_and_call self, :given_scenario, name
|
55
|
+
World.run_with_suspended_listeners(
|
56
|
+
self, :'given scenario', name, GivenScenario.new(name))
|
45
57
|
end
|
46
58
|
|
47
59
|
def Given(name, *args, &block)
|
@@ -57,7 +69,7 @@ module RBehave
|
|
57
69
|
end
|
58
70
|
|
59
71
|
def pending(message = 'todo')
|
60
|
-
raise PendingException, message unless RBehave::Runner.dry_run
|
72
|
+
raise PendingException, message unless RBehave::Runner.dry_run
|
61
73
|
end
|
62
74
|
end
|
63
75
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rbehave
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2007-06-04 00:00:00 +01:00
|
8
8
|
summary: RBehave
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -62,6 +62,8 @@ files:
|
|
62
62
|
- behaviour/examples/rbehave/step_mother_behaviour.rb
|
63
63
|
- behaviour/examples/rbehave/documenter/plain_text_documenter_behaviour.rb
|
64
64
|
- behaviour/examples/rbehave/simple_step_behaviour.rb
|
65
|
+
- behaviour/examples/rbehave/scenario_behaviour.rb
|
66
|
+
- behaviour/examples/builders.rb
|
65
67
|
- examples/game-of-life/life/game.rb
|
66
68
|
- examples/game-of-life/life/grid.rb
|
67
69
|
- examples/game-of-life/.loadpath
|