aslakhellesoy-cucumber 0.1.5 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +228 -0
- data/License.txt +20 -0
- data/Manifest.txt +226 -0
- data/README.txt +41 -0
- data/Rakefile +9 -0
- data/TODO.txt +26 -0
- data/bin/cucumber +5 -0
- data/config/hoe.rb +69 -0
- data/config/requirements.rb +15 -0
- data/cucumber.yml +1 -0
- data/examples/calculator_ruby_features/Rakefile +6 -0
- data/examples/calculator_ruby_features/features/addition.rb +23 -0
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
- data/examples/cs/README.textile +22 -0
- data/examples/cs/Rakefile +12 -0
- data/examples/cs/features/hello.feature +11 -0
- data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
- data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
- data/examples/cs/features/tree.feature +9 -0
- data/examples/cs/src/Hello.cs +18 -0
- data/examples/dos_line_endings/Rakefile +6 -0
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -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/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/da/features/summering.feature +17 -0
- data/examples/i18n/da/lib/kalkulator.rb +11 -0
- data/examples/i18n/en/Rakefile +5 -0
- data/examples/i18n/en/features/addition.feature +17 -0
- data/examples/i18n/en/features/division.feature +10 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/en/lib/calculator.rb +14 -0
- data/examples/i18n/es/Rakefile +6 -0
- data/examples/i18n/es/features/adicion.feature +17 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
- data/examples/i18n/es/lib/calculador.rb +11 -0
- data/examples/i18n/et/Rakefile +6 -0
- data/examples/i18n/et/features/liitmine.feature +17 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
- data/examples/i18n/et/lib/kalkulaator.rb +10 -0
- data/examples/i18n/fr/Rakefile +6 -0
- data/examples/i18n/fr/features/addition.feature +13 -0
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
- 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/i18n/ja/README.txt +5 -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/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/no/features/summering.feature +17 -0
- data/examples/i18n/no/lib/kalkulator.rb +11 -0
- data/examples/i18n/pt/Rakefile +6 -0
- data/examples/i18n/pt/features/adicao.feature +10 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
- 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/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/se/features/summering.feature +17 -0
- data/examples/i18n/se/lib/kalkulator.rb +11 -0
- data/examples/i18n/zh-CN/Rakefile +6 -0
- data/examples/i18n/zh-CN/features/addition.feature +17 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
- data/examples/java/README.textile +22 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/step_definitons/hello_steps.rb +25 -0
- data/examples/java/features/step_definitons/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/selenium/Rakefile +6 -0
- data/examples/selenium/features/search.feature +9 -0
- data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
- data/examples/tickets/Rakefile +11 -0
- data/examples/tickets/cucumber.yml +2 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
- data/examples/tickets/features/tickets.feature +22 -0
- data/examples/watir/Rakefile +6 -0
- data/examples/watir/features/search.feature +9 -0
- data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
- data/features/see_features.feature +8 -0
- data/features/steps/features_steps.rb +9 -0
- data/gem_tasks/deployment.rake +34 -0
- data/gem_tasks/environment.rake +7 -0
- data/gem_tasks/features.rake +6 -0
- data/gem_tasks/fix_cr_lf.rake +10 -0
- data/gem_tasks/flog.rake +4 -0
- data/gem_tasks/gemspec.rake +6 -0
- data/gem_tasks/rspec.rake +21 -0
- data/gem_tasks/treetop.rake +41 -0
- 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 +39 -0
- data/lib/cucumber/broadcaster.rb +20 -0
- data/lib/cucumber/cli.rb +269 -0
- data/lib/cucumber/core_ext/proc.rb +54 -0
- data/lib/cucumber/core_ext/string.rb +22 -0
- data/lib/cucumber/executor.rb +170 -0
- data/lib/cucumber/formatters.rb +1 -0
- data/lib/cucumber/formatters/ansicolor.rb +111 -0
- data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
- data/lib/cucumber/formatters/cucumber.css +132 -0
- data/lib/cucumber/formatters/cucumber.js +11 -0
- data/lib/cucumber/formatters/html_formatter.rb +128 -0
- data/lib/cucumber/formatters/jquery.js +32 -0
- data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
- data/lib/cucumber/formatters/profile_formatter.rb +92 -0
- data/lib/cucumber/formatters/progress_formatter.rb +58 -0
- data/lib/cucumber/languages.yml +235 -0
- data/lib/cucumber/model.rb +1 -0
- data/lib/cucumber/model/table.rb +28 -0
- data/lib/cucumber/rails/rspec.rb +12 -0
- data/lib/cucumber/rails/world.rb +73 -0
- data/lib/cucumber/rake/task.rb +101 -0
- data/lib/cucumber/step_methods.rb +49 -0
- data/lib/cucumber/step_mother.rb +89 -0
- data/lib/cucumber/tree.rb +18 -0
- data/lib/cucumber/tree/feature.rb +61 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/given_scenario.rb +13 -0
- data/lib/cucumber/tree/scenario.rb +158 -0
- data/lib/cucumber/tree/step.rb +134 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/tree/top_down_visitor.rb +23 -0
- data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
- 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 +1591 -0
- data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
- 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 +1591 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
- data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
- 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 +1591 -0
- data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
- data/lib/cucumber/version.rb +9 -0
- data/rails_generators/cucumber/USAGE +11 -0
- data/rails_generators/cucumber/cucumber_generator.rb +30 -0
- data/rails_generators/cucumber/templates/cucumber +7 -0
- data/rails_generators/cucumber/templates/cucumber.rake +7 -0
- data/rails_generators/cucumber/templates/env.rb +8 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +46 -0
- data/rails_generators/feature/USAGE +12 -0
- data/rails_generators/feature/feature_generator.rb +16 -0
- data/rails_generators/feature/templates/feature.erb +28 -0
- data/rails_generators/feature/templates/steps.erb +22 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy +14 -0
- data/script/destroy.cmd +1 -0
- data/script/generate +14 -0
- data/script/generate.cmd +1 -0
- data/script/txt2html +74 -0
- data/script/txt2html.cmd +1 -0
- data/setup.rb +1585 -0
- data/spec/cucumber/broadcaster_spec.rb +27 -0
- data/spec/cucumber/cli_spec.rb +242 -0
- data/spec/cucumber/core_ext/proc_spec.rb +45 -0
- data/spec/cucumber/core_ext/string_spec.rb +34 -0
- data/spec/cucumber/executor_spec.rb +222 -0
- data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
- data/spec/cucumber/formatters/features.html +269 -0
- data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
- data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
- data/spec/cucumber/model/table_spec.rb +20 -0
- data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
- data/spec/cucumber/rails/stubs/test_help.rb +1 -0
- data/spec/cucumber/rails/world_spec.rb +11 -0
- data/spec/cucumber/sell_cucumbers.feature +19 -0
- data/spec/cucumber/step_mother_spec.rb +74 -0
- data/spec/cucumber/tree/feature_spec.rb +12 -0
- data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
- data/spec/cucumber/tree/scenario_spec.rb +76 -0
- data/spec/cucumber/tree/step_spec.rb +50 -0
- data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
- data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
- data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
- data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
- data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
- data/spec/cucumber/treetop_parser/spaces.feature +10 -0
- data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
- data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +19 -0
- metadata +151 -35
@@ -0,0 +1,192 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Formatters
|
5
|
+
describe ProfileFormatter do
|
6
|
+
attr_reader :io, :formatter
|
7
|
+
|
8
|
+
def mock_proc(stubs={})
|
9
|
+
stub(Proc, {:to_comment_line => '# steps/example_steps.rb:11'}.merge(stubs))
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_step(stubs={})
|
13
|
+
stub('step', {:keyword => 'Given',
|
14
|
+
:actual_keyword => 'Given',
|
15
|
+
:format => 'test',
|
16
|
+
:row? => false,
|
17
|
+
:file => 'test.feature',
|
18
|
+
:line => 5,
|
19
|
+
:regexp_args_proc => [nil, nil, mock_proc]}.merge(stubs))
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
@io = StringIO.new
|
24
|
+
step_mother = stub('step_mother')
|
25
|
+
@formatter = ProfileFormatter.new(io, step_mother)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should print a heading" do
|
29
|
+
formatter.visit_features(nil)
|
30
|
+
|
31
|
+
io.string.should eql("Profiling enabled.\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should record the current time when starting a new step" do
|
35
|
+
now = Time.now
|
36
|
+
Time.stub!(:now).and_return(now)
|
37
|
+
formatter.step_executing('should foo', nil, nil)
|
38
|
+
|
39
|
+
formatter.instance_variable_get("@step_time").should == now
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "grouping recorded passed steps" do
|
43
|
+
|
44
|
+
before(:each) do
|
45
|
+
now = Time.now
|
46
|
+
formatter.instance_variable_set("@step_time", now)
|
47
|
+
Time.stub!(:now).and_return(now, now)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should group by regular expressions and actual keyword" do
|
51
|
+
step_1 = mock_step(:actual_keyword => 'Given')
|
52
|
+
step_2 = mock_step(:actual_keyword => 'Given')
|
53
|
+
|
54
|
+
formatter.step_passed(step_1, /nihon/, nil)
|
55
|
+
formatter.step_passed(step_2, /ichiban/, nil)
|
56
|
+
|
57
|
+
step_times = formatter.instance_variable_get("@step_times")
|
58
|
+
|
59
|
+
step_times.has_key?('Given /nihon/').should be_true
|
60
|
+
step_times.has_key?('Given /ichiban/').should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should use a previous step's keyword when recording row steps" do
|
64
|
+
step = mock_step(:actual_keyword => 'Given')
|
65
|
+
step_row = mock_step(:row? => true)
|
66
|
+
|
67
|
+
formatter.step_passed(step, /nihon/, [])
|
68
|
+
formatter.step_passed(step_row, /nihon/, [])
|
69
|
+
|
70
|
+
step_times = formatter.instance_variable_get("@step_times")
|
71
|
+
|
72
|
+
step_times['Given /nihon/'].length.should == 2
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should correctly record a passed step" do
|
78
|
+
formatter.step_executing(nil, nil, nil)
|
79
|
+
formatter.step_passed(mock_step(:format => 'she doth teach the torches to burn bright', :actual_keyword => 'Given'), nil, nil)
|
80
|
+
formatter.dump
|
81
|
+
|
82
|
+
io.string.should include('Given she doth teach the torches to burn bright')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should correctly record a passed step row" do
|
86
|
+
formatter.step_executing(nil, nil, nil)
|
87
|
+
formatter.step_passed(mock_step(:row? => true), /example/, ['fitty'])
|
88
|
+
formatter.dump
|
89
|
+
|
90
|
+
io.string.should include('fitty')
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should calculate the mean step execution time" do
|
94
|
+
now = Time.now
|
95
|
+
Time.stub!(:now).and_return(now, now+5, now, now+1)
|
96
|
+
|
97
|
+
2.times do
|
98
|
+
formatter.step_executing(mock_step, nil, nil)
|
99
|
+
formatter.step_passed(mock_step, nil, nil)
|
100
|
+
end
|
101
|
+
|
102
|
+
formatter.dump
|
103
|
+
|
104
|
+
io.string.should include('3.0000000')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should display file and line comment for step invocation" do
|
108
|
+
step = mock_step(:format => 'test', :actual_keyword => 'Given', :file => 'test.feature', :line => 5)
|
109
|
+
|
110
|
+
formatter.step_executing(step, nil, nil)
|
111
|
+
formatter.step_passed(step, nil, nil)
|
112
|
+
formatter.dump
|
113
|
+
|
114
|
+
@io.string.should include("# test.feature:5")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should display file and line comment for step definition" do
|
118
|
+
step = mock_step(:format => 'test', :actual_keyword => 'Given',
|
119
|
+
:regexp_args_proc => [/test/, nil, mock_proc(:to_comment_line => '# steps/example_steps.rb:11')])
|
120
|
+
|
121
|
+
formatter.step_executing(step, nil, nil)
|
122
|
+
formatter.step_passed(step, nil, nil)
|
123
|
+
formatter.dump
|
124
|
+
|
125
|
+
@io.string.should include("# steps/example_steps.rb:11")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should show the performance times of the step invocations for a step definition" do
|
129
|
+
now = Time.now
|
130
|
+
Time.stub!(:now).and_return(now, now+5, now, now+1)
|
131
|
+
|
132
|
+
step = mock_step(:format => 'step invocation', :actual_keyword => 'Given')
|
133
|
+
|
134
|
+
2.times do
|
135
|
+
formatter.step_executing(step, /example/, nil)
|
136
|
+
formatter.step_passed(step, /example/, nil)
|
137
|
+
end
|
138
|
+
|
139
|
+
formatter.dump
|
140
|
+
|
141
|
+
io.string.should include("3.0000000 Given /example/")
|
142
|
+
io.string.should include("5.0000000 Given step invocation")
|
143
|
+
io.string.should include("1.0000000 Given step invocation")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should sort the step invocations in descending order" do
|
147
|
+
now = Time.now
|
148
|
+
Time.stub!(:now).and_return(now, now+1, now, now+5)
|
149
|
+
|
150
|
+
step = mock_step(:format => 'step invocation', :actual_keyword => 'Given')
|
151
|
+
|
152
|
+
2.times do
|
153
|
+
formatter.step_executing(step, /example 1/, nil)
|
154
|
+
formatter.step_passed(step, /example 1/, nil)
|
155
|
+
end
|
156
|
+
|
157
|
+
formatter.dump
|
158
|
+
io_string_lines = io.string.split("\n")
|
159
|
+
|
160
|
+
io_string_lines.at(-2).should include('5.0000000')
|
161
|
+
io_string_lines.at(-1).should include('1.0000000')
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should print the top average 10 step results" do
|
165
|
+
formatter.instance_variable_set("@step_time", Time.now)
|
166
|
+
|
167
|
+
11.times do |test_number|
|
168
|
+
step_regexp = Regexp.new "unique_test_#{test_number}"
|
169
|
+
formatter.step_passed(mock_step(:format => 'test', :actual_keyword => 'Given',
|
170
|
+
:regexp_args_proc => [step_regexp, nil, mock_proc]), step_regexp, nil)
|
171
|
+
end
|
172
|
+
|
173
|
+
formatter.dump
|
174
|
+
|
175
|
+
io.string.scan(/unique_test_\d+/).length.should == 10
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should print the top 5 step invocations for step definition" do
|
179
|
+
formatter.instance_variable_set("@step_time", Time.now)
|
180
|
+
|
181
|
+
10.times do |test_number|
|
182
|
+
formatter.step_passed(mock_step(:format => 'please invocate me', :actual_keyword => 'Given'), nil, nil)
|
183
|
+
end
|
184
|
+
|
185
|
+
formatter.dump
|
186
|
+
|
187
|
+
io.string.scan(/please invocate me/).length.should == 5
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Formatters
|
5
|
+
describe ProgressFormatter do
|
6
|
+
it "should print . when passed" do
|
7
|
+
io = StringIO.new
|
8
|
+
formatter = ProgressFormatter.new io
|
9
|
+
step = stub('step',
|
10
|
+
:error => nil
|
11
|
+
)
|
12
|
+
formatter.step_passed(step,nil,nil)
|
13
|
+
io.string.should =~ /^\.$/
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should print F when failed" do
|
17
|
+
io = StringIO.new
|
18
|
+
formatter = ProgressFormatter.new io
|
19
|
+
step = stub('step',
|
20
|
+
:error => StandardError.new
|
21
|
+
)
|
22
|
+
formatter.step_failed(step,nil,nil)
|
23
|
+
io.string.should =~ /^\F$/
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should print P when pending" do
|
27
|
+
io = StringIO.new
|
28
|
+
formatter = ProgressFormatter.new io
|
29
|
+
step = stub('step',
|
30
|
+
:error => Pending.new,
|
31
|
+
:scenario => mock('scenario')
|
32
|
+
)
|
33
|
+
formatter.step_pending(step,nil,nil)
|
34
|
+
io.string.should =~ /^\P$/
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should print _ when skipped" do
|
38
|
+
io = StringIO.new
|
39
|
+
formatter = ProgressFormatter.new io
|
40
|
+
formatter.step_skipped(nil,nil,nil)
|
41
|
+
io.string.should =~ /^_$/
|
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
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Model
|
5
|
+
describe Table do
|
6
|
+
it "should convert into hash-array" do
|
7
|
+
raw = [
|
8
|
+
%w{name gender},
|
9
|
+
%w{aslak male},
|
10
|
+
%w{patty female},
|
11
|
+
]
|
12
|
+
ha = Table.new(raw).hashes
|
13
|
+
ha.should == [
|
14
|
+
{'name' => 'aslak', 'gender' => 'male'},
|
15
|
+
{'name' => 'patty', 'gender' => 'female'}
|
16
|
+
]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Define some stubs to fake Rails...
|
2
|
+
module ActiveRecord
|
3
|
+
class Base
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module ActionController
|
8
|
+
class Base
|
9
|
+
end
|
10
|
+
class IntegrationTest
|
11
|
+
def self.use_transactional_fixtures=(x)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Dispatcher
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# This file is loaded by rails/world.rb
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Sell cucumbers
|
2
|
+
As a cucumber farmer
|
3
|
+
I want to sell cucumbers
|
4
|
+
So that I buy meat
|
5
|
+
|
6
|
+
Scenario: Sell a dozen
|
7
|
+
Given there are 5 cucumbers
|
8
|
+
When I sell 12 cucumbers
|
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
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
describe StepMother do
|
5
|
+
it "should report file and line numbers for both duplicate step definitions" do
|
6
|
+
m = StepMother.new
|
7
|
+
|
8
|
+
m.register_step_proc /Three (.*) mice/ do |disability|
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
m.register_step_proc /Three (.*) mice/ do |disability|
|
13
|
+
end
|
14
|
+
violated("Should raise error")
|
15
|
+
rescue => e
|
16
|
+
e.message.should =~ %r{Duplicate step definitions:.+step_mother_spec\.rb:8:in `/Three \(\.\*\) mice/'.+step_mother_spec\.rb\:12:in `/Three \(\.\*\) mice/'}m
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should report file and line numbers for multiple step definitions" do
|
22
|
+
m = StepMother.new
|
23
|
+
|
24
|
+
m.register_step_proc /Three (.*) mice/ do |disability|
|
25
|
+
end
|
26
|
+
|
27
|
+
m.register_step_proc /Three blind (.*)/ do |animal|
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
m.regexp_args_proc('Three blind mice')
|
32
|
+
violated("Should raise error")
|
33
|
+
rescue => e
|
34
|
+
e.message.should =~ %r{Multiple step definitions match "Three blind mice":
|
35
|
+
|
36
|
+
.+step_mother_spec\.rb:24:in `/Three \(\.\*\) mice/'
|
37
|
+
.+step_mother_spec\.rb:27:in `/Three blind \(\.\*\)/'
|
38
|
+
|
39
|
+
}m
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should mark step as pending when it doesn't match any procs" do
|
44
|
+
pending "think some more about what to expect here" do
|
45
|
+
m = StepMother.new
|
46
|
+
step = mock('step')
|
47
|
+
step.should_receive(:pending!)
|
48
|
+
raise "FIXME"
|
49
|
+
m.execute(step)
|
50
|
+
end
|
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
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Tree
|
5
|
+
describe Feature do
|
6
|
+
it "should have padding_length 2 when alone" do
|
7
|
+
feature = Feature.new('header')
|
8
|
+
feature.padding_length.should == 2
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
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
|