cucumber 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +38 -3
- data/Manifest.txt +17 -1
- data/README.txt +2 -39
- data/bin/cucumber +1 -1
- data/examples/calculator_ruby_features/features/addition.rb +16 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +1 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -0
- data/examples/i18n/fr/features/addition.feature +13 -11
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +6 -2
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -0
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +1 -0
- data/examples/selenium/features/search.feature +1 -1
- data/examples/selenium/features/step_definitons/stories_steps.rb +2 -3
- data/examples/tickets/features/lib/eatting_machine.rb +18 -0
- data/examples/tickets/features/lib/pantry.rb +20 -0
- data/examples/tickets/features/scenario_outline.feature +64 -0
- data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +34 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +4 -0
- data/gem_tasks/fix_cr_lf.rake +1 -1
- data/gem_tasks/yard.rake +8 -0
- data/lib/autotest/cucumber_mixin.rb +3 -3
- data/lib/cucumber.rb +2 -0
- data/lib/cucumber/broadcaster.rb +1 -1
- data/lib/cucumber/cli.rb +87 -42
- data/lib/cucumber/core_ext/exception.rb +20 -0
- data/lib/cucumber/core_ext/string.rb +1 -1
- data/lib/cucumber/executor.rb +35 -18
- data/lib/cucumber/formatters/ansicolor.rb +65 -74
- data/lib/cucumber/formatters/html_formatter.rb +33 -10
- data/lib/cucumber/formatters/pretty_formatter.rb +58 -16
- data/lib/cucumber/formatters/progress_formatter.rb +3 -0
- data/lib/cucumber/formatters/unicode.rb +27 -0
- data/lib/cucumber/languages.yml +6 -4
- data/lib/cucumber/platform.rb +1 -0
- data/lib/cucumber/rails/world.rb +6 -6
- data/lib/cucumber/step_mother.rb +3 -0
- data/lib/cucumber/tree/feature.rb +28 -2
- data/lib/cucumber/tree/scenario.rb +62 -1
- data/lib/cucumber/tree/step.rb +32 -1
- data/lib/cucumber/treetop_parser/feature.treetop.erb +54 -7
- data/lib/cucumber/treetop_parser/feature_ar.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_cy.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_da.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_de.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_en.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_es.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_et.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_fr.rb +389 -30
- data/lib/cucumber/treetop_parser/feature_id.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_it.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ja.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_lt.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_nl.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_no.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_pl.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_pt.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ro.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ro2.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_ru.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_se.rb +377 -18
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +377 -18
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/world.rb +1 -0
- data/lib/cucumber/world/pending.rb +22 -0
- data/rails_generators/cucumber/templates/env.rb +1 -0
- data/rails_generators/feature/feature_generator.rb +22 -2
- data/rails_generators/feature/templates/feature.erb +15 -12
- data/rails_generators/feature/templates/steps.erb +16 -14
- data/spec/cucumber/cli_spec.rb +87 -6
- data/spec/cucumber/executor_spec.rb +102 -30
- data/spec/cucumber/formatters/ansicolor_spec.rb +10 -10
- data/spec/cucumber/formatters/html_formatter_spec.rb +30 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +139 -4
- data/spec/cucumber/formatters/progress_formatter_spec.rb +16 -0
- data/spec/cucumber/tree/feature_spec.rb +84 -5
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +73 -0
- data/spec/cucumber/tree/row_step_outline_spec.rb +38 -0
- data/spec/cucumber/tree/scenario_outline_spec.rb +50 -0
- data/spec/cucumber/tree/step_outline_spec.rb +17 -0
- data/spec/cucumber/tree/step_spec.rb +9 -0
- data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +3 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +22 -0
- data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +7 -0
- data/spec/cucumber/treetop_parser/scenario_outline.feature +16 -0
- data/spec/cucumber/world/pending_spec.rb +46 -0
- data/spec/spec_helper.rb +2 -1
- metadata +19 -4
- data/TODO.txt +0 -26
@@ -6,24 +6,24 @@ module Cucumber
|
|
6
6
|
describe ANSIColor do
|
7
7
|
include ANSIColor
|
8
8
|
|
9
|
-
|
9
|
+
after do
|
10
10
|
::Term::ANSIColor.coloring = true
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
it "should wrap passed_param with bold green and reset to green" do
|
14
|
+
passed_param("foo").should == "\e[32m\e[1mfoo\e[0m\e[0m\e[32m"
|
15
15
|
end
|
16
|
-
|
17
|
-
it "should wrap
|
18
|
-
passed("foo").should == "\e[
|
16
|
+
|
17
|
+
it "should wrap passed in green" do
|
18
|
+
passed("foo").should == "\e[32mfoo\e[0m"
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should
|
22
|
-
passed.should == "\e[
|
21
|
+
it "should not reset passed if there are no arguments" do
|
22
|
+
passed.should == "\e[32m"
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should
|
26
|
-
comment("foo").should == "\e[
|
25
|
+
it "should wrap comments in grey" do
|
26
|
+
comment("foo").should == "\e[90mfoo\e[0m"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should not generate ansi codes when colors are disabled" do
|
@@ -33,6 +33,18 @@ module Cucumber
|
|
33
33
|
|
34
34
|
describe HtmlFormatter do
|
35
35
|
SIMPLE_DIR = File.dirname(__FILE__) + '/../../../examples/simple'
|
36
|
+
|
37
|
+
def mock_row_step(stubs = {})
|
38
|
+
mock('row step', {:id => 1, :outline? => true, :regexp_args_proc => [nil, nil, nil], :visible_args => []}.merge(stubs))
|
39
|
+
end
|
40
|
+
|
41
|
+
def mock_step(stubs = {})
|
42
|
+
mock('step', {:id => 1, :keyword => 'Given', :format => '', :regexp_args_proc => [nil, nil, nil]}.merge(stubs))
|
43
|
+
end
|
44
|
+
|
45
|
+
def mock_scenario_outline(stubs = {})
|
46
|
+
mock('scenario outline', {:table_header => nil, :accept => nil}.merge(stubs))
|
47
|
+
end
|
36
48
|
|
37
49
|
before do
|
38
50
|
p = Cucumber::TreetopParser::FeatureParser.new
|
@@ -68,6 +80,24 @@ module Cucumber
|
|
68
80
|
@io.string.should include(column_header)
|
69
81
|
end
|
70
82
|
end
|
83
|
+
|
84
|
+
it "should only show arguments in a row step outline that are visible" do
|
85
|
+
@formatter.visit_row_step(mock_row_step(:outline? => true, :regexp_args_proc => [nil, ['mouse', 'monkey'], nil], :visible_args => ['mouse']))
|
86
|
+
|
87
|
+
@io.string.should_not =~ /monkey/
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should escape placeholders in step outline" do
|
91
|
+
CGI.should_receive(:escapeHTML).with("I'm a <placeholder>")
|
92
|
+
|
93
|
+
@formatter.visit_step_outline(mock_step(:format => "I'm a <placeholder>"))
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should show Scenario Outline keyword for scenario outline" do
|
97
|
+
@formatter.visit_scenario_outline(mock_scenario_outline(:name => "outline", :accept => nil))
|
98
|
+
|
99
|
+
@io.string.should =~ /Scenario Outline/
|
100
|
+
end
|
71
101
|
|
72
102
|
end
|
73
103
|
end
|
@@ -13,9 +13,16 @@ module Cucumber
|
|
13
13
|
:padding_length => 2,
|
14
14
|
:file => 'test',
|
15
15
|
:line => 1,
|
16
|
-
:row? => false
|
16
|
+
:row? => false,
|
17
|
+
:forced_to_pending? => false,
|
18
|
+
:regexp_args_proc => [nil, nil, mock_proc],
|
19
|
+
:outline? => false}.merge(stubs))
|
17
20
|
end
|
18
21
|
|
22
|
+
def mock_step_outline(stubs={})
|
23
|
+
mock_step({:outline? => true}.merge(stubs))
|
24
|
+
end
|
25
|
+
|
19
26
|
def mock_scenario(stubs={})
|
20
27
|
stub('scenario', {
|
21
28
|
:name => 'test',
|
@@ -23,7 +30,12 @@ module Cucumber
|
|
23
30
|
:pending? => false,
|
24
31
|
:file => 'file',
|
25
32
|
:line => 1,
|
26
|
-
:padding_length => 2
|
33
|
+
:padding_length => 2,
|
34
|
+
:outline? => false}.merge(stubs))
|
35
|
+
end
|
36
|
+
|
37
|
+
def mock_scenario_outline(stubs={})
|
38
|
+
mock_scenario({:outline? => true}.merge(stubs))
|
27
39
|
end
|
28
40
|
|
29
41
|
def mock_feature(stubs={})
|
@@ -36,8 +48,16 @@ module Cucumber
|
|
36
48
|
:backtrace => 'example backtrace'}.merge(stubs))
|
37
49
|
end
|
38
50
|
|
39
|
-
def mock_proc
|
40
|
-
stub(Proc, :to_comment_line => '# steps/example_steps.rb:11')
|
51
|
+
def mock_proc(stubs={})
|
52
|
+
stub(Proc, {:to_comment_line => '# steps/example_steps.rb:11'}.merge(stubs))
|
53
|
+
end
|
54
|
+
|
55
|
+
before do
|
56
|
+
::Term::ANSIColor.coloring = false
|
57
|
+
end
|
58
|
+
|
59
|
+
after do
|
60
|
+
::Term::ANSIColor.coloring = true
|
41
61
|
end
|
42
62
|
|
43
63
|
it "should print step file and line when passed" do
|
@@ -81,6 +101,27 @@ module Cucumber
|
|
81
101
|
io.string.should =~ /\n\n Scenario: spacey/
|
82
102
|
end
|
83
103
|
|
104
|
+
it "should distinguish a scenario outline from a scenario when displaying keywords" do
|
105
|
+
io = StringIO.new
|
106
|
+
formatter = PrettyFormatter.new(io, mock('step_mother'))
|
107
|
+
|
108
|
+
formatter.scenario_executing(mock_scenario_outline(:name => 'outliner'))
|
109
|
+
|
110
|
+
io.string.should =~ /Scenario Outline: outliner/
|
111
|
+
end
|
112
|
+
|
113
|
+
%w{passed pending failed skipped}.each do |result|
|
114
|
+
it "should only show visible placeholder values in #{result} step " do
|
115
|
+
io = StringIO.new
|
116
|
+
formatter = PrettyFormatter.new(io, mock('step_mother'))
|
117
|
+
formatter.instance_variable_set('@table_column_widths', [0])
|
118
|
+
|
119
|
+
formatter.send("step_#{result}".to_sym, mock_step_outline(:row? => true, :visible_args => ['monkey'], :padding_length => 2), nil, ['mouse'])
|
120
|
+
|
121
|
+
io.string.should =~ /monkey/
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
84
125
|
{'should' => true, 'should not' => false}.each do |should_or_should_not, show_snippet|
|
85
126
|
describe "snippets option #{show_snippet}" do
|
86
127
|
|
@@ -136,6 +177,12 @@ module Cucumber
|
|
136
177
|
end
|
137
178
|
end
|
138
179
|
|
180
|
+
it "should display feature file and line for step outline" do
|
181
|
+
@formatter.step_traced(mock_step_outline(:file => "features/example.feature", :line => 11, :padding_length => 2), nil, nil)
|
182
|
+
|
183
|
+
@io.string.should include("Given formatted yes # features/example.feature:11")
|
184
|
+
end
|
185
|
+
|
139
186
|
it "should display feature file and line for pending step" do
|
140
187
|
@formatter.step_pending(mock_step(:name => 'test', :file => 'features/example.feature', :line => 5, :padding_length => 2), nil, nil)
|
141
188
|
|
@@ -199,6 +246,94 @@ module Cucumber
|
|
199
246
|
}.should_not raise_error(TypeError)
|
200
247
|
end
|
201
248
|
|
249
|
+
describe "pending messages" do
|
250
|
+
|
251
|
+
before(:each) do
|
252
|
+
@io = StringIO.new
|
253
|
+
@formatter = PrettyFormatter.new @io, mock('step_mother')
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should show pending message for step" do
|
257
|
+
@formatter.step_pending(mock_step(:keyword => 'Given', :forced_to_pending? => true, :error => ForcedPending.new("please implement me")), /yatta/, nil)
|
258
|
+
|
259
|
+
@formatter.dump
|
260
|
+
|
261
|
+
@io.string.should include("Given /yatta/ (please implement me)")
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should show pending step's file and line" do
|
265
|
+
@formatter.step_pending(mock_step(:forced_to_pending? => true, :error => ForcedPending.new("please implement me"),
|
266
|
+
:regexp_args_proc => [nil, nil, mock_proc(:to_comment_line => "steps/example_steps.rb:11")]), nil, nil)
|
267
|
+
|
268
|
+
@formatter.dump
|
269
|
+
|
270
|
+
@io.string.should include("steps/example_steps.rb:11")
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should not show duplicates" do
|
274
|
+
@formatter.step_pending(mock_step(:keyword => 'Given', :forced_to_pending? => true, :error => ForcedPending.new("please implement me")), /yatta/, [])
|
275
|
+
@formatter.step_pending(mock_step(:forced_to_pending? => true, :error => ForcedPending.new("please implement me"), :row? => true), /yatta/, [])
|
276
|
+
|
277
|
+
@formatter.dump
|
278
|
+
|
279
|
+
@io.string.scan(/please implement me/).length.should_not == 2
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should ignore messages from steps that where not forced to pending" do
|
283
|
+
@formatter.step_pending(mock_step(:keyword => 'Given', :forced_to_pending? => false, :error => Pending.new("do not show me")), nil, [])
|
284
|
+
|
285
|
+
@formatter.dump
|
286
|
+
|
287
|
+
@io.string.should_not include("do not show me")
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "no pending messages" do
|
293
|
+
|
294
|
+
it "should not show any pending message information" do
|
295
|
+
io = StringIO.new
|
296
|
+
formatter = PrettyFormatter.new io, mock('step_mother')
|
297
|
+
|
298
|
+
formatter.dump
|
299
|
+
|
300
|
+
io.string.should_not include("Pending Notes:\n")
|
301
|
+
end
|
302
|
+
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should show number of pending steps that have no step definition" do
|
306
|
+
io = StringIO.new
|
307
|
+
formatter = PrettyFormatter.new io, mock('step_mother')
|
308
|
+
|
309
|
+
formatter.step_pending(mock_step(:error => ForcedPending.new, :forced_to_pending? => true), nil, [])
|
310
|
+
formatter.step_pending(mock_step(:error => Pending.new, :forced_to_pending? => false), nil, [])
|
311
|
+
|
312
|
+
formatter.dump
|
313
|
+
|
314
|
+
io.string.should include("1 with no step definition")
|
315
|
+
end
|
316
|
+
|
317
|
+
describe "colour" do
|
318
|
+
|
319
|
+
before(:all) do
|
320
|
+
Term::ANSIColor.coloring = true
|
321
|
+
end
|
322
|
+
|
323
|
+
after(:all) do
|
324
|
+
Term::ANSIColor.coloring = false
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should show the scenario outline keyword and title as pending blue" do
|
328
|
+
::Term::ANSIColor.coloring = true
|
329
|
+
io = StringIO.new
|
330
|
+
formatter = PrettyFormatter.new io, mock('step_mother')
|
331
|
+
formatter.scenario_executing(mock_scenario(:outline? => true, :name => 'blue'))
|
332
|
+
|
333
|
+
io.string.should =~ /\e\[36m\s*Scenario Outline: blue\e\[0m/
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
202
337
|
end
|
203
338
|
end
|
204
339
|
end
|
@@ -3,6 +3,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Cucumber
|
4
4
|
module Formatters
|
5
5
|
describe ProgressFormatter do
|
6
|
+
before do
|
7
|
+
::Term::ANSIColor.coloring = false
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
::Term::ANSIColor.coloring = true
|
12
|
+
end
|
13
|
+
|
6
14
|
it "should print . when passed" do
|
7
15
|
io = StringIO.new
|
8
16
|
formatter = ProgressFormatter.new io
|
@@ -41,6 +49,14 @@ module Cucumber
|
|
41
49
|
io.string.should =~ /^_$/
|
42
50
|
end
|
43
51
|
|
52
|
+
it "should print nothing when traced" do
|
53
|
+
io = StringIO.new
|
54
|
+
formatter = ProgressFormatter.new io
|
55
|
+
formatter.step_traced(nil, nil, nil)
|
56
|
+
|
57
|
+
io.string.should =~ /^$/
|
58
|
+
end
|
59
|
+
|
44
60
|
describe "scenario without any steps" do
|
45
61
|
before :each do
|
46
62
|
@io = StringIO.new
|
@@ -4,6 +4,16 @@ module Cucumber
|
|
4
4
|
module Tree
|
5
5
|
describe Feature do
|
6
6
|
|
7
|
+
def mock_scenario(stubs = {})
|
8
|
+
mock("scenario", {:update_table_column_widths => nil,
|
9
|
+
:outline? => false,
|
10
|
+
:table_header= => nil}.merge(stubs))
|
11
|
+
end
|
12
|
+
|
13
|
+
def mock_scenario_outline(stubs = {})
|
14
|
+
mock_scenario({:outline? => true, :row? => false, :table_header= => nil}.merge(stubs))
|
15
|
+
end
|
16
|
+
|
7
17
|
it "should have padding_length 2 when alone" do
|
8
18
|
feature = Feature.new('header')
|
9
19
|
feature.padding_length.should == 2
|
@@ -14,30 +24,99 @@ module Cucumber
|
|
14
24
|
it "should create a new scenario for a feature" do
|
15
25
|
feature = Feature.new('header')
|
16
26
|
|
17
|
-
Scenario.should_receive(:new).with(feature, 'test scenario', "
|
27
|
+
Scenario.should_receive(:new).with(feature, 'test scenario', "29")
|
18
28
|
|
19
29
|
feature.Scenario('test scenario') {}
|
20
30
|
end
|
21
31
|
|
22
32
|
end
|
23
33
|
|
34
|
+
describe "creating a Scenario Outline" do
|
35
|
+
|
36
|
+
it "should create a new scenario outline for feature" do
|
37
|
+
feature = Feature.new('header')
|
38
|
+
|
39
|
+
ScenarioOutline.should_receive(:new).with(feature, 'test', '41')
|
40
|
+
|
41
|
+
feature.ScenarioOutline('test') {}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
24
46
|
describe "creating a Table" do
|
47
|
+
|
48
|
+
before(:each) do
|
49
|
+
@feature = Feature.new('header')
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "previous scenario is a scenario outline" do
|
53
|
+
|
54
|
+
it "should create a row scenario outline for feature" do
|
55
|
+
mock_scenario_outline = mock_scenario_outline(:outline? => true)
|
56
|
+
Scenario.stub!(:new).and_return(mock_scenario_outline)
|
57
|
+
@feature.add_scenario('scenario', 5)
|
58
|
+
|
59
|
+
RowScenarioOutline.should_receive(:new).with(@feature, mock_scenario_outline, ['1', '2'], anything)
|
60
|
+
|
61
|
+
@feature.Table do |t|
|
62
|
+
t | "input_1" | "input_2" | t
|
63
|
+
t | 1 | 2 | t
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "previous scenario was a regular scenario" do
|
70
|
+
|
71
|
+
it "should create a row scenario for feature" do
|
72
|
+
mock_scenario = mock_scenario(:outline? => false)
|
73
|
+
Scenario.stub!(:new).and_return(mock_scenario)
|
74
|
+
@feature.add_scenario('scenario', 5)
|
75
|
+
|
76
|
+
RowScenario.should_receive(:new).with(@feature, mock_scenario, ['1', '2'], anything)
|
77
|
+
|
78
|
+
@feature.Table do |t|
|
79
|
+
t | "input_1" | "input_2" | t
|
80
|
+
t | 1 | 2 | t
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
25
85
|
|
26
86
|
it "should set the table header of the template scenario" do
|
27
|
-
|
28
|
-
mock_scenario = mock("scenario", :update_table_column_widths => nil)
|
87
|
+
mock_scenario = mock("scenario", :update_table_column_widths => nil, :outline? => false)
|
29
88
|
Scenario.stub!(:new).and_return(mock_scenario)
|
30
|
-
feature.add_scenario('scenario', 5)
|
89
|
+
@feature.add_scenario('scenario', 5)
|
31
90
|
|
32
91
|
mock_scenario.should_receive(:table_header=).with(["input_1", "input_2"])
|
33
92
|
|
34
|
-
feature.Table do |t|
|
93
|
+
@feature.Table do |t|
|
35
94
|
t | "input_1" | "input_2" | t
|
36
95
|
t | 1 | 2 | t
|
37
96
|
end
|
38
97
|
end
|
39
98
|
|
40
99
|
end
|
100
|
+
|
101
|
+
it "should create a new row scenario outline" do
|
102
|
+
feature = Feature.new('header')
|
103
|
+
|
104
|
+
RowScenarioOutline.should_receive(:new)
|
105
|
+
|
106
|
+
feature.add_row_scenario_outline(mock_scenario_outline, [], 1)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should visit scenario outline" do
|
110
|
+
feature = Feature.new('header')
|
111
|
+
ScenarioOutline.stub!(:new).and_return(mock_scenario_outline(:outline? => true, :row? => false))
|
112
|
+
feature.add_scenario_outline(nil, nil)
|
113
|
+
mock_visitor = mock('visitor', :visit_header => nil)
|
114
|
+
|
115
|
+
mock_visitor.should_receive(:visit_scenario_outline)
|
116
|
+
|
117
|
+
feature.accept(mock_visitor)
|
118
|
+
end
|
119
|
+
|
41
120
|
end
|
42
121
|
end
|
43
122
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Tree
|
5
|
+
describe RowScenarioOutline do
|
6
|
+
|
7
|
+
def mock_feature
|
8
|
+
mock_feature = mock("feature")
|
9
|
+
end
|
10
|
+
|
11
|
+
def mock_scenario(stubs ={})
|
12
|
+
mock("scenario", {:update_table_column_widths => nil}.merge(stubs))
|
13
|
+
end
|
14
|
+
|
15
|
+
def mock_step(stubs = {})
|
16
|
+
mock("step", {:arity => 0}.merge(stubs))
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should indicate scenario is a scenario outline" do
|
20
|
+
outline = RowScenarioOutline.new(mock_feature, mock_scenario, [], 1)
|
21
|
+
|
22
|
+
outline.should be_a_outline
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "steps" do
|
26
|
+
|
27
|
+
it "should create a new step with placeholders in template scenario steps replaced with values from scenario row" do
|
28
|
+
mock_step = mock_step(:keyword => 'Given', :name => '<animal> burning bright')
|
29
|
+
mock_scenario = mock_scenario(:table_header => ["animal"], :steps => [mock_step] )
|
30
|
+
outline = RowScenarioOutline.new(mock_feature, mock_scenario, ["tiger"], 1)
|
31
|
+
|
32
|
+
RowStepOutline.should_receive(:new).with(outline, mock_step, 'tiger burning bright', ["tiger"], 1)
|
33
|
+
|
34
|
+
outline.steps
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should leave the scenario template's name unchanged when replacing placeholders" do
|
38
|
+
mock_step = mock_step(:keyword => 'Given', :name => '<animal> burning bright', :extra_args => [])
|
39
|
+
mock_scenario = mock_scenario(:table_header => ["animal"], :steps => [mock_step] )
|
40
|
+
outline = RowScenarioOutline.new(mock_feature, mock_scenario, ["tiger"], 1)
|
41
|
+
|
42
|
+
outline.steps
|
43
|
+
|
44
|
+
mock_step.name.should == '<animal> burning bright'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should leave the step name untouched if it has no placeholders" do
|
48
|
+
mock_step = mock_step(:keyword => 'Given', :name => 'beauty too rich for earth too dear')
|
49
|
+
mock_scenario = mock_scenario(:table_header => ["animal"], :steps => [mock_step] )
|
50
|
+
outline = RowScenarioOutline.new(mock_feature, mock_scenario, ["tiger"], 1)
|
51
|
+
|
52
|
+
RowStepOutline.should_receive(:new).with(outline, mock_step, 'beauty too rich for earth too dear', [], 1)
|
53
|
+
|
54
|
+
outline.steps
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should ensure that created steps do not contain values already used in previous steps" do
|
58
|
+
mock_step_1 = mock_step(:keyword => 'Given', :name => '<animal> eating')
|
59
|
+
mock_step_2 = mock_step(:keyword => 'Given', :name => 'eating <animal>')
|
60
|
+
mock_scenario = mock_scenario(:table_header => ["animal"], :steps => [mock_step_1, mock_step_2] )
|
61
|
+
outline = RowScenarioOutline.new(mock_feature, mock_scenario, ["tiger"], 1)
|
62
|
+
|
63
|
+
RowStepOutline.should_receive(:new).with(anything, anything, anything, ['tiger'], anything)
|
64
|
+
RowStepOutline.should_receive(:new).with(anything, anything, anything, [], anything)
|
65
|
+
|
66
|
+
outline.steps
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|