cucumber 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +86 -3
- data/Manifest.txt +93 -44
- data/Rakefile +5 -1
- data/bin/cucumber +1 -0
- data/cucumber.yml +1 -1
- data/examples/calculator_ruby_features/features/{steps → step_definitons}/calculator_steps.rb +0 -0
- data/examples/cs/features/{steps → step_definitons}/hello_steps.rb +0 -0
- data/examples/cs/features/{steps → step_definitons}/tree_steps.rb +0 -0
- data/examples/i18n/README.textile +18 -0
- data/examples/i18n/Rakefile +16 -0
- data/examples/i18n/ar/Rakefile +6 -0
- data/examples/i18n/ar/features/addition.feature +17 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/ar/lib/calculator.rb +10 -0
- data/examples/i18n/da/Rakefile +6 -0
- data/examples/{danish_calculator/features/steps → i18n/da/features/step_definitons}/kalkulator_steps.rb +0 -0
- data/examples/{danish_calculator → i18n/da}/features/summering.feature +1 -1
- data/examples/{danish_calculator → i18n/da}/lib/kalkulator.rb +0 -0
- data/examples/{swedish_calculator → i18n/en}/Rakefile +1 -1
- data/examples/{calculator → i18n/en}/features/addition.feature +0 -0
- data/examples/{calculator → i18n/en}/features/division.feature +0 -0
- data/examples/{calculator/features/steps → i18n/en/features/step_definitons}/calculator_steps.rb +0 -0
- data/examples/{calculator → i18n/en}/lib/calculator.rb +0 -2
- data/examples/i18n/es/Rakefile +6 -0
- data/examples/{spanish_calculator → i18n/es}/features/adicion.feature +1 -1
- data/examples/{spanish_calculator/features/steps → i18n/es/features/step_definitons}/calculador_steps.rb +0 -0
- data/examples/{spanish_calculator/lib/Calculador.rb → i18n/es/lib/calculador.rb} +0 -0
- data/examples/i18n/et/Rakefile +6 -0
- data/examples/i18n/et/features/liitmine.feature +17 -0
- data/examples/{estonian_calculator/features → i18n/et/features/step_definitions}/kalkulaator_steps.rb +2 -11
- data/examples/i18n/et/lib/kalkulaator.rb +10 -0
- data/examples/i18n/fr/Rakefile +6 -0
- data/examples/{calculatrice_francaise_avec_soit_scenario → i18n/fr}/features/addition.feature +0 -0
- data/examples/{calculatrice_francaise_avec_soit_scenario/features → i18n/fr/features/step_definitions}/calculatrice_steps.rb +2 -11
- data/examples/i18n/fr/lib/calculatrice.rb +10 -0
- data/examples/i18n/id/Rakefile +6 -0
- data/examples/i18n/id/features/addition.feature +17 -0
- data/examples/i18n/id/features/division.feature +10 -0
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/id/lib/calculator.rb +14 -0
- data/examples/i18n/it/Rakefile +6 -0
- data/examples/i18n/it/features/somma.feature +10 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
- data/examples/i18n/it/lib/calcolatrice.rb +11 -0
- data/examples/{calculator → i18n/ja}/README.txt +0 -0
- data/examples/i18n/ja/Rakefile +6 -0
- data/examples/i18n/ja/features/addition.feature +17 -0
- data/examples/i18n/ja/features/division.feature +10 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
- data/examples/i18n/ja/lib/calculator.rb +14 -0
- data/examples/i18n/no/Rakefile +6 -0
- data/examples/{norwegian_calculator/features/steps → i18n/no/features/step_definitons}/kalkulator_steps.rb +0 -0
- data/examples/{norwegian_calculator → i18n/no}/features/summering.feature +0 -0
- data/examples/{norwegian_calculator → i18n/no}/lib/kalkulator.rb +0 -0
- data/examples/i18n/pt/Rakefile +6 -0
- data/examples/{portuguese_calculator → i18n/pt}/features/adicao.feature +0 -0
- data/examples/{portuguese_calculator/features → i18n/pt/features/step_definitions}/calculadora_steps.rb +2 -11
- data/examples/i18n/pt/lib/calculadora.rb +10 -0
- data/examples/i18n/ro/Rakefile +6 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
- data/examples/i18n/ro/features/suma.feature +10 -0
- data/examples/i18n/ro/lib/calculator.rb +11 -0
- data/examples/i18n/se/Rakefile +6 -0
- data/examples/{swedish_calculator/features/steps → i18n/se/features/step_definitons}/kalkulator_steps.rb +0 -0
- data/examples/{swedish_calculator → i18n/se}/features/summering.feature +0 -0
- data/examples/{swedish_calculator → i18n/se}/lib/kalkulator.rb +0 -0
- data/examples/i18n/zh-CN/Rakefile +6 -0
- data/examples/{chinese_simplified_calculator → i18n/zh-CN}/features/addition.feature +0 -0
- data/examples/{chinese_simplified_calculator/features/steps → i18n/zh-CN/features/step_definitons}/calculator_steps.rb +0 -0
- data/examples/{chinese_simplified_calculator → i18n/zh-CN}/lib/calculator.rb +0 -0
- data/examples/java/features/{steps → step_definitons}/hello_steps.rb +0 -0
- data/examples/java/features/{steps → step_definitons}/tree_steps.rb +0 -0
- data/examples/selenium/features/{steps → step_definitons}/stories_steps.rb +0 -0
- data/examples/tickets/features/{steps → step_definitons}/tickets_steps.rb +0 -0
- data/examples/watir/features/search.feature +2 -2
- data/examples/watir/features/{steps → step_definitons}/stories_steps.rb +0 -0
- data/gem_tasks/treetop.rake +1 -9
- data/lib/autotest/cucumber.rb +6 -0
- data/lib/autotest/cucumber_mixin.rb +109 -0
- data/lib/autotest/cucumber_rails.rb +6 -0
- data/lib/autotest/cucumber_rails_rspec.rb +6 -0
- data/lib/autotest/cucumber_rspec.rb +6 -0
- data/lib/autotest/discover.rb +9 -0
- data/lib/cucumber.rb +4 -0
- data/lib/cucumber/broadcaster.rb +20 -0
- data/lib/cucumber/cli.rb +139 -48
- data/lib/cucumber/core_ext/proc.rb +2 -3
- data/lib/cucumber/executor.rb +59 -32
- data/lib/cucumber/formatters.rb +1 -1
- data/lib/cucumber/formatters/ansicolor.rb +3 -4
- data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
- data/lib/cucumber/formatters/pretty_formatter.rb +99 -42
- data/lib/cucumber/formatters/progress_formatter.rb +21 -5
- data/lib/cucumber/languages.yml +125 -10
- data/lib/cucumber/rails/world.rb +1 -1
- data/lib/cucumber/rake/task.rb +52 -26
- data/lib/cucumber/step_mother.rb +7 -1
- data/lib/cucumber/tree/feature.rb +8 -6
- data/lib/cucumber/tree/scenario.rb +34 -15
- data/lib/cucumber/tree/step.rb +3 -1
- data/lib/cucumber/treetop_parser/feature.treetop.erb +15 -10
- data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_da.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_de.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_es.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_et.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_fr.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_nl.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_no.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ru.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_se.rb +238 -240
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +238 -240
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/USAGE +11 -0
- data/rails_generators/cucumber/cucumber_generator.rb +9 -6
- data/rails_generators/cucumber/templates/cucumber +6 -1
- data/rails_generators/cucumber/templates/{common_webrat.rb → webrat_steps.rb} +4 -0
- data/rails_generators/feature/USAGE +12 -0
- data/rails_generators/feature/feature_generator.rb +3 -4
- data/spec/cucumber/broadcaster_spec.rb +27 -0
- data/spec/cucumber/cli_spec.rb +211 -23
- data/spec/cucumber/executor_spec.rb +104 -14
- data/spec/cucumber/formatters/ansicolor_spec.rb +9 -1
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +119 -26
- data/spec/cucumber/formatters/profile_formatter_spec.rb +1 -2
- data/spec/cucumber/formatters/progress_formatter_spec.rb +22 -1
- data/spec/cucumber/sell_cucumbers.feature +10 -0
- data/spec/cucumber/step_mother_spec.rb +21 -0
- data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
- data/spec/cucumber/tree/scenario_spec.rb +47 -8
- data/spec/cucumber/tree/step_spec.rb +19 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +2 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +7 -3
- data/spec/spec_helper.rb +2 -0
- metadata +97 -48
- data/examples/calculator/Rakefile +0 -5
- data/examples/calculatrice_francaise_avec_soit_scenario/Rakefile +0 -6
- data/examples/chinese_simplified_calculator/Rakefile +0 -6
- data/examples/danish_calculator/Rakefile +0 -6
- data/examples/estonian_calculator/Rakefile +0 -6
- data/examples/estonian_calculator/features/liitmine.feature +0 -16
- data/examples/norwegian_calculator/Rakefile +0 -6
- data/examples/portuguese_calculator/Rakefile +0 -6
- data/examples/spanish_calculator/Rakefile +0 -6
@@ -6,6 +6,14 @@ module Cucumber
|
|
6
6
|
describe ANSIColor do
|
7
7
|
include ANSIColor
|
8
8
|
|
9
|
+
before do
|
10
|
+
::Term::ANSIColor.coloring = true
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
::Term::ANSIColor.coloring = false
|
15
|
+
end
|
16
|
+
|
9
17
|
it "should wrap string in bold green for #passed with string arg" do
|
10
18
|
passed("foo").should == "\e[0m\e[1m\e[32mfoo\e[0m\e[0m"
|
11
19
|
end
|
@@ -19,7 +27,7 @@ module Cucumber
|
|
19
27
|
end
|
20
28
|
|
21
29
|
it "should not generate ansi codes when colors are disabled" do
|
22
|
-
|
30
|
+
::Term::ANSIColor.coloring = false
|
23
31
|
passed("foo").should == "foo"
|
24
32
|
end
|
25
33
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber::Formatters
|
4
|
+
describe AutotestFormatter do
|
5
|
+
before(:each) do
|
6
|
+
@io = StringIO.new
|
7
|
+
@formatter = AutotestFormatter.new @io
|
8
|
+
@scenario = mock('scenario', :name => "Doing tricky things")
|
9
|
+
@step = mock('step', :scenario => @scenario)
|
10
|
+
end
|
11
|
+
|
12
|
+
%w{failed skipped pending}.each do |didnt_pass|
|
13
|
+
it "should print a scenario's name when it has a #{didnt_pass} step" do
|
14
|
+
@formatter.send("step_#{didnt_pass}".to_sym, @step, mock('regexp'), mock('args'))
|
15
|
+
@io.string.should == "Doing tricky things\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not print the same scenario's name twice" do
|
20
|
+
another_step = mock('another step', :scenario => @scenario)
|
21
|
+
@formatter.send("step_failed".to_sym, @step, mock('regexp'), mock('args'))
|
22
|
+
@formatter.send("step_skipped".to_sym, another_step, mock('regexp'), mock('args'))
|
23
|
+
@io.string.should == "Doing tricky things\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,36 +3,43 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Cucumber
|
4
4
|
module Formatters
|
5
5
|
describe PrettyFormatter do
|
6
|
-
|
6
|
+
|
7
7
|
def mock_step(stubs={})
|
8
8
|
stub('step', {
|
9
|
-
:keyword => 'Given',
|
9
|
+
:keyword => 'Given',
|
10
10
|
:format => 'formatted yes',
|
11
11
|
:name => 'example',
|
12
12
|
:error => nil,
|
13
|
+
:padding_length => 2,
|
14
|
+
:file => 'test',
|
15
|
+
:line => 1,
|
13
16
|
:row? => false}.merge(stubs))
|
14
17
|
end
|
15
|
-
|
18
|
+
|
16
19
|
def mock_scenario(stubs={})
|
17
20
|
stub('scenario', {
|
18
21
|
:name => 'test',
|
19
|
-
:row? => false
|
22
|
+
:row? => false,
|
23
|
+
:pending? => false,
|
24
|
+
:file => 'file',
|
25
|
+
:line => 1,
|
26
|
+
:padding_length => 2}.merge(stubs))
|
20
27
|
end
|
21
28
|
|
22
29
|
def mock_feature(stubs={})
|
23
30
|
stub("feature", stubs)
|
24
31
|
end
|
25
|
-
|
32
|
+
|
26
33
|
def mock_error(stubs={})
|
27
34
|
stub('error', {
|
28
|
-
:message => 'failed',
|
35
|
+
:message => 'failed',
|
29
36
|
:backtrace => 'example backtrace'}.merge(stubs))
|
30
37
|
end
|
31
|
-
|
38
|
+
|
32
39
|
def mock_proc
|
33
40
|
stub(Proc, :to_comment_line => '# steps/example_steps.rb:11')
|
34
41
|
end
|
35
|
-
|
42
|
+
|
36
43
|
it "should print step file and line when passed" do
|
37
44
|
io = StringIO.new
|
38
45
|
formatter = PrettyFormatter.new io, StepMother.new
|
@@ -42,70 +49,156 @@ module Cucumber
|
|
42
49
|
formatter.step_passed(step, nil, nil)
|
43
50
|
io.string.should == " Given formatted yes\n"
|
44
51
|
end
|
52
|
+
|
53
|
+
describe "scenario without any steps" do
|
54
|
+
before :each do
|
55
|
+
@io = StringIO.new
|
56
|
+
@formatter = PrettyFormatter.new(@io, StepMother.new)
|
57
|
+
@scenario = mock_scenario(:name => "title", :pending? => true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should display as pending when executing" do
|
61
|
+
@formatter.should_receive(:pending).with(" Scenario: title")
|
62
|
+
@formatter.scenario_executing(@scenario)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should display as pending in the dump" do
|
66
|
+
@formatter.scenario_executing(@scenario)
|
67
|
+
@formatter.dump
|
68
|
+
@io.string.should include("1 scenarios pending")
|
69
|
+
end
|
70
|
+
end
|
45
71
|
|
46
|
-
|
72
|
+
it "should put a line between last row scenario and new scenario" do
|
73
|
+
io = StringIO.new
|
74
|
+
formatter = PrettyFormatter.new io, mock('step_mother'), :source => true
|
75
|
+
scenario = mock_scenario(:row? => true)
|
76
|
+
|
77
|
+
formatter.scenario_executing(scenario)
|
78
|
+
formatter.scenario_executed(scenario)
|
79
|
+
formatter.scenario_executing(mock_scenario(:name => 'spacey', :row? => false))
|
80
|
+
|
81
|
+
io.string.should =~ /\n\n Scenario: spacey/
|
82
|
+
end
|
83
|
+
|
84
|
+
{'should' => true, 'should not' => false}.each do |should_or_should_not, show_snippet|
|
85
|
+
describe "snippets option #{show_snippet}" do
|
86
|
+
|
87
|
+
it "#{should_or_should_not} show snippet for pending step" do
|
88
|
+
@io = StringIO.new
|
89
|
+
step_mother = mock('step_mother', :has_step_definition? => false)
|
90
|
+
@formatter = PrettyFormatter.new @io, step_mother, :snippets => show_snippet
|
91
|
+
|
92
|
+
@formatter.step_pending(mock_step(:actual_keyword => 'Given', :name => 'pending step snippet'), nil, nil)
|
93
|
+
@formatter.dump
|
94
|
+
|
95
|
+
@io.string.send(should_or_should_not.gsub(' ','_').to_sym, include("Given /^pending step snippet$/ do"))
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should escape snippets which have special regular expression characters" do
|
102
|
+
@io = StringIO.new
|
103
|
+
step_mother = mock('step_mother', :has_step_definition? => false)
|
104
|
+
@formatter = PrettyFormatter.new @io, step_mother, :snippets => true
|
105
|
+
|
106
|
+
@formatter.step_pending(mock_step(:actual_keyword => 'Given', :name => "$1 millon /'s"), nil, nil)
|
107
|
+
@formatter.dump
|
108
|
+
|
109
|
+
@io.string.should include("Given /^\\$1 millon \\/'s$/ do")
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should not show the snippet for a step which already has a step definition" do
|
113
|
+
@io = StringIO.new
|
114
|
+
step_mother = mock('step_mother', :has_step_definition? => true)
|
115
|
+
@formatter = PrettyFormatter.new @io, step_mother, :snippets => true
|
116
|
+
|
117
|
+
@formatter.step_pending(mock_step(:actual_keyword => 'Given', :name => 'pending step snippet'), nil, nil)
|
118
|
+
@formatter.dump
|
119
|
+
|
120
|
+
@io.string.should_not include("Given /^pending step snippet$/ do")
|
121
|
+
end
|
47
122
|
|
123
|
+
describe "show source option true" do
|
124
|
+
|
48
125
|
before(:each) do
|
49
126
|
@io = StringIO.new
|
50
127
|
step_mother = mock('step_mother')
|
51
128
|
@formatter = PrettyFormatter.new @io, step_mother, :source => true
|
52
129
|
end
|
53
|
-
|
130
|
+
|
54
131
|
%w{passed failed skipped}.each do |result|
|
55
|
-
it "should display step source for
|
132
|
+
it "should display step source for #{result} step" do
|
56
133
|
@formatter.send("step_#{result}".to_sym, mock_step(:regexp_args_proc => [nil, nil, mock_proc], :error => StandardError.new, :padding_length => 2), nil, nil)
|
57
|
-
|
134
|
+
|
58
135
|
@io.string.should include("Given formatted yes # steps/example_steps.rb:11")
|
59
136
|
end
|
60
137
|
end
|
61
138
|
|
62
139
|
it "should display feature file and line for pending step" do
|
63
140
|
@formatter.step_pending(mock_step(:name => 'test', :file => 'features/example.feature', :line => 5, :padding_length => 2), nil, nil)
|
64
|
-
|
141
|
+
|
65
142
|
@io.string.should include("Given test # features/example.feature:5")
|
66
|
-
end
|
67
|
-
|
143
|
+
end
|
144
|
+
|
68
145
|
it "should display file and line for scenario" do
|
69
|
-
@formatter.scenario_executing(mock_scenario(:name => "title", :file => 'features/example.feature', :line => 2 , :padding_length => 2))
|
70
|
-
|
146
|
+
@formatter.scenario_executing(mock_scenario(:name => "title", :file => 'features/example.feature', :line => 2 , :padding_length => 2, :pending? => false))
|
147
|
+
|
71
148
|
@io.string.should include("Scenario: title # features/example.feature:2")
|
72
149
|
end
|
73
|
-
|
150
|
+
|
74
151
|
it "should display file for feature" do
|
75
|
-
@formatter.
|
152
|
+
@formatter.feature_executing(mock_feature(:file => 'features/example.feature', :padding_length => 2))
|
76
153
|
@formatter.header_executing("Feature: test\n In order to ...\n As a ...\n I want to ...\n")
|
77
|
-
|
154
|
+
|
78
155
|
@io.string.should include("Feature: test # features/example.feature\n")
|
79
156
|
@io.string.should include("In order to ...\n")
|
80
157
|
@io.string.should include("As a ...\n")
|
81
158
|
@io.string.should include("I want to ...\n")
|
82
159
|
end
|
83
|
-
|
160
|
+
|
84
161
|
it "should align step comments" do
|
85
162
|
step_1 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "1", :padding_length => 10)
|
86
163
|
step_4 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "4444", :padding_length => 7)
|
87
164
|
step_9 = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :format => "999999999", :padding_length => 2)
|
88
|
-
|
165
|
+
|
89
166
|
@formatter.step_passed(step_1, nil, nil)
|
90
167
|
@formatter.step_passed(step_4, nil, nil)
|
91
168
|
@formatter.step_passed(step_9, nil, nil)
|
92
|
-
|
169
|
+
|
93
170
|
@io.string.should include("Given 1 # steps/example_steps.rb:11")
|
94
171
|
@io.string.should include("Given 4444 # steps/example_steps.rb:11")
|
95
172
|
@io.string.should include("Given 999999999 # steps/example_steps.rb:11")
|
96
173
|
end
|
97
|
-
|
174
|
+
|
98
175
|
it "should align step comments with respect to their scenario's comment" do
|
99
176
|
step = mock_step(:regexp_args_proc => [nil, nil, mock_proc], :error => StandardError.new, :padding_length => 6)
|
100
177
|
|
101
|
-
@formatter.scenario_executing(mock_scenario(:name => "very long title", :file => 'features/example.feature', :line => 5, :steps => [step], :padding_length => 2))
|
178
|
+
@formatter.scenario_executing(mock_scenario(:name => "very long title", :file => 'features/example.feature', :line => 5, :steps => [step], :padding_length => 2, :pending? => false))
|
102
179
|
@formatter.step_passed(step, nil, nil)
|
103
|
-
|
180
|
+
|
104
181
|
@io.string.should include("Scenario: very long title # features/example.feature:5")
|
105
182
|
@io.string.should include(" Given formatted yes # steps/example_steps.rb:11")
|
106
183
|
end
|
107
184
|
|
108
185
|
end
|
186
|
+
|
187
|
+
it "should reset the column count correctly" do
|
188
|
+
io = StringIO.new
|
189
|
+
formatter = PrettyFormatter.new io, mock('step_mother'), :source => true
|
190
|
+
|
191
|
+
large_scenario = mock_scenario(:row? => false, :table_column_widths => [3,3,5,4,4], :table_header => %w(one two three four five))
|
192
|
+
formatter.scenario_executing(large_scenario)
|
193
|
+
formatter.scenario_executed(large_scenario)
|
194
|
+
|
195
|
+
small_scenario = mock_scenario(:row? => false, :table_column_widths => [3,3], :table_header => %w(one two))
|
196
|
+
formatter.scenario_executing(small_scenario)
|
197
|
+
lambda {
|
198
|
+
formatter.scenario_executed(small_scenario)
|
199
|
+
}.should_not raise_error(TypeError)
|
200
|
+
end
|
201
|
+
|
109
202
|
end
|
110
203
|
end
|
111
204
|
end
|
@@ -177,8 +177,7 @@ module Cucumber
|
|
177
177
|
|
178
178
|
it "should print the top 5 step invocations for step definition" do
|
179
179
|
formatter.instance_variable_set("@step_time", Time.now)
|
180
|
-
|
181
|
-
|
180
|
+
|
182
181
|
10.times do |test_number|
|
183
182
|
formatter.step_passed(mock_step(:format => 'please invocate me', :actual_keyword => 'Given'), nil, nil)
|
184
183
|
end
|
@@ -27,7 +27,8 @@ module Cucumber
|
|
27
27
|
io = StringIO.new
|
28
28
|
formatter = ProgressFormatter.new io
|
29
29
|
step = stub('step',
|
30
|
-
:error => Pending.new
|
30
|
+
:error => Pending.new,
|
31
|
+
:scenario => mock('scenario')
|
31
32
|
)
|
32
33
|
formatter.step_pending(step,nil,nil)
|
33
34
|
io.string.should =~ /^\P$/
|
@@ -39,6 +40,26 @@ module Cucumber
|
|
39
40
|
formatter.step_skipped(nil,nil,nil)
|
40
41
|
io.string.should =~ /^_$/
|
41
42
|
end
|
43
|
+
|
44
|
+
describe "scenario without any steps" do
|
45
|
+
before :each do
|
46
|
+
@io = StringIO.new
|
47
|
+
@formatter = ProgressFormatter.new(@io)
|
48
|
+
@feature = stub("feature", :header => "Feature Header")
|
49
|
+
@scenario = stub("scenario", :feature => @feature, :name => "Scenario Title", :row? => false, :pending? => true)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should print a P when executing" do
|
53
|
+
@formatter.should_receive(:pending).with("P")
|
54
|
+
@formatter.scenario_executing(@scenario)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should display as pending in the dump" do
|
58
|
+
@formatter.scenario_executing(@scenario)
|
59
|
+
@formatter.dump
|
60
|
+
@io.string.should include("Feature Header (Scenario Title)")
|
61
|
+
end
|
62
|
+
end
|
42
63
|
end
|
43
64
|
end
|
44
65
|
end
|
@@ -7,3 +7,13 @@ Feature: Sell cucumbers
|
|
7
7
|
Given there are 5 cucumbers
|
8
8
|
When I sell 12 cucumbers
|
9
9
|
Then I should owe 7 cucumbers
|
10
|
+
|
11
|
+
Scenario: Sell twenty
|
12
|
+
Given there are 5 cucumbers
|
13
|
+
When I sell 20 cucumbers
|
14
|
+
Then I should owe 15 cucumbers
|
15
|
+
|
16
|
+
Scenario: Sell fifty
|
17
|
+
Given there are 5 cucumbers
|
18
|
+
When I sell 50 cucumbers
|
19
|
+
Then I should owe 45 cucumbers
|
@@ -49,5 +49,26 @@ module Cucumber
|
|
49
49
|
m.execute(step)
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
it "should mark a step as pending if it does not have a proc" do
|
54
|
+
m = StepMother.new
|
55
|
+
m.register_step_proc /I have no body/
|
56
|
+
regexp, args, proc = m.regexp_args_proc "I have no body"
|
57
|
+
proc.should == StepMother::PENDING
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should report that a step has a definition if the step is registered" do
|
61
|
+
m = StepMother.new
|
62
|
+
m.register_step_proc /I am a real step definition/ do end
|
63
|
+
|
64
|
+
m.has_step_definition?('I am a real step definition').should be_true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should report that a step does not have a definition if it has not been registered" do
|
68
|
+
m = StepMother.new
|
69
|
+
|
70
|
+
m.has_step_definition?('I am a step without a definition').should be_false
|
71
|
+
end
|
72
|
+
|
52
73
|
end
|
53
74
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Tree
|
5
|
+
describe RowScenario do
|
6
|
+
|
7
|
+
describe "pending?" do
|
8
|
+
before :each do
|
9
|
+
@scenario = Scenario.new(nil, '', 1)
|
10
|
+
@row_scenario = RowScenario.new(mock('feature'), @scenario, [], 1)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return true if the template scenario has no steps" do
|
14
|
+
@row_scenario.should be_pending
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return false if the template scenario has no steps" do
|
18
|
+
@scenario.create_step('Given', 'a long step', 1)
|
19
|
+
@row_scenario.should_not be_pending
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,36 +2,75 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module Tree
|
5
|
-
describe Scenario do
|
5
|
+
describe Scenario do
|
6
6
|
xit "should reuse steps in GivenScenario" do
|
7
7
|
given_scenario = GivenScenario.new(scenario_2, "First", 99)
|
8
|
-
|
8
|
+
|
9
9
|
scenario_2.create_step(given_scenario)
|
10
10
|
scenario_2.create_step(step_a)
|
11
11
|
scenario_2.steps.should == [step_1, step_2, step_a]
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should have padding_length 2 when alone" do
|
15
15
|
scenario = Scenario.new(nil, 'test', 1)
|
16
16
|
scenario.padding_length.should == 2
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should include indent when padding to step" do
|
20
20
|
scenario = Scenario.new(nil, '', 1)
|
21
21
|
scenario.create_step('Given', 'a long step', 1)
|
22
22
|
|
23
|
-
#Scenario:
|
23
|
+
#Scenario: *********
|
24
24
|
# Given a long step
|
25
|
-
scenario.padding_length.should == 9 +
|
25
|
+
scenario.padding_length.should == 9 + Scenario::INDENT
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should ignore step padding if scenario is longer than all steps" do
|
29
29
|
scenario = Scenario.new(nil, 'Very long scenario and then some', 1)
|
30
30
|
scenario.create_step('Given', 'test', 1)
|
31
|
+
|
32
|
+
scenario.padding_length.should == 2
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "utf-8 strings" do
|
36
|
+
describe "when calculating padding" do
|
37
|
+
|
38
|
+
it "should take into consideration utf-8 scenario names" do
|
39
|
+
scenario = Scenario.new(nil, 'こんばんは', 1)
|
40
|
+
scenario.create_step('Given', 'a long step', 1)
|
41
|
+
|
42
|
+
#Scenario: こんばんは****
|
43
|
+
# Given a long step
|
44
|
+
scenario.padding_length.should == 4 + Scenario::INDENT
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should take into consideration a utf-8 keyword for 'scenario'" do
|
48
|
+
Cucumber.language.stub!(:[]).with('scenario').and_return("シナリオ")
|
49
|
+
scenario = Scenario.new(nil, '', 1)
|
50
|
+
scenario.create_step('Given', 'step', 1)
|
31
51
|
|
32
|
-
|
52
|
+
#シナリオ: ******
|
53
|
+
# Given step
|
54
|
+
scenario.padding_length.should == 6 + Scenario::INDENT
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
33
58
|
end
|
34
59
|
|
60
|
+
describe "pending?" do
|
61
|
+
before :each do
|
62
|
+
@scenario = Scenario.new(nil, '', 1)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return true if there aren't any steps" do
|
66
|
+
@scenario.should be_pending
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return false if there are steps" do
|
70
|
+
@scenario.create_step('Given', 'a long step', 1)
|
71
|
+
@scenario.should_not be_pending
|
72
|
+
end
|
73
|
+
end
|
35
74
|
end
|
36
75
|
end
|
37
76
|
end
|