kosmas58-cucumber 0.1.16.6 → 0.1.99.21
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/History.txt +126 -2
- data/License.txt +1 -1
- data/Manifest.txt +0 -270
- data/Rakefile +1 -1
- data/bin/cucumber +2 -2
- data/config/hoe.rb +7 -2
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/README.textile +1 -1
- data/examples/i18n/Rakefile +3 -3
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -6
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/de/features/addition.feature +6 -6
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/en/features/addition.feature +6 -6
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/es/features/adicion.feature +11 -12
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +7 -10
- data/examples/i18n/es/lib/calculador.rb +4 -1
- data/examples/i18n/et/features/liitmine.feature +7 -6
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
- data/examples/i18n/fi/features/yhteenlasku.feature +2 -2
- data/examples/i18n/fr/features/addition.feature +2 -2
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/id/features/addition.feature +6 -6
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -3
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/lt/features/addition.feature +7 -6
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +7 -7
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/jbehave/README.textile +17 -0
- data/examples/jbehave/features/support/env.rb +7 -0
- data/examples/jbehave/features/trading.feature +24 -0
- data/examples/jbehave/pom.xml +48 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +65 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/{calculator_ruby_features → self_test}/Rakefile +3 -3
- data/examples/self_test/features/background/failing_background.feature +10 -0
- data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
- data/examples/self_test/features/background/multiline_args_background.feature +32 -0
- data/examples/self_test/features/background/passing_background.feature +10 -0
- data/examples/self_test/features/background/pending_background.feature +10 -0
- data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
- data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
- data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
- data/examples/self_test/features/lots_of_undefined.feature +8 -0
- data/examples/self_test/features/outline_sample.feature +11 -5
- data/examples/self_test/features/sample.feature +8 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +53 -4
- data/examples/self_test/features/support/env.rb +1 -0
- data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
- data/examples/tickets/features/172.feature +28 -0
- data/examples/tickets/features/177/1.feature +29 -0
- data/examples/tickets/features/177/2.feature +21 -0
- data/examples/tickets/features/177/3.feature +18 -0
- data/examples/tickets/features/180.feature +7 -0
- data/examples/tickets/features/scenario_outline.feature +6 -1
- data/examples/tickets/features/step_definitons/tickets_steps.rb +27 -3
- data/examples/tickets/features/tickets.feature +4 -0
- data/features/background.feature +223 -0
- data/features/cucumber_cli.feature +218 -98
- data/features/cucumber_cli_outlines.feature +54 -37
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +32 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +2 -1
- data/gem_tasks/flog.rake +1 -1
- data/gem_tasks/gemspec.rake +2 -2
- data/gem_tasks/jar.rake +67 -0
- data/lib/autotest/cucumber_mixin.rb +17 -23
- data/lib/cucumber.rb +63 -11
- data/lib/cucumber/ast.rb +29 -0
- data/lib/cucumber/ast/background.rb +88 -0
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +26 -0
- data/lib/cucumber/ast/feature.rb +66 -0
- data/lib/cucumber/ast/features.rb +39 -0
- data/lib/cucumber/ast/filter.rb +22 -0
- data/lib/cucumber/ast/outline_table.rb +49 -0
- data/lib/cucumber/ast/py_string.rb +52 -0
- data/lib/cucumber/ast/scenario.rb +103 -0
- data/lib/cucumber/ast/scenario_outline.rb +92 -0
- data/lib/cucumber/ast/step.rb +161 -0
- data/lib/cucumber/ast/steps.rb +13 -0
- data/lib/cucumber/ast/table.rb +218 -0
- data/lib/cucumber/ast/tags.rb +40 -0
- data/lib/cucumber/ast/visitor.rb +109 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli/configuration.rb +339 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +100 -0
- data/lib/cucumber/core_ext/exception.rb +41 -8
- data/lib/cucumber/core_ext/instance_exec.rb +54 -0
- data/lib/cucumber/core_ext/proc.rb +29 -65
- data/lib/cucumber/core_ext/string.rb +19 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/{formatters → formatter}/ansicolor.rb +14 -16
- data/lib/cucumber/formatter/color_io.rb +17 -0
- data/lib/cucumber/formatter/console.rb +119 -0
- data/lib/cucumber/formatter/cucumber.css +55 -0
- data/lib/cucumber/formatter/cucumber.sass +49 -0
- data/lib/cucumber/formatter/html.rb +121 -0
- data/lib/cucumber/formatter/pretty.rb +167 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter/rerun.rb +35 -0
- data/lib/cucumber/formatter/unicode.rb +35 -0
- data/lib/cucumber/formatters/unicode.rb +2 -35
- data/lib/cucumber/jbehave.rb +102 -0
- data/lib/cucumber/languages.yml +128 -75
- data/lib/cucumber/parser.rb +43 -0
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1490 -0
- data/lib/cucumber/parser/feature.tt +188 -0
- data/lib/cucumber/parser/i18n.tt +31 -0
- data/lib/cucumber/parser/table.rb +402 -0
- data/lib/cucumber/parser/table.tt +59 -0
- data/lib/cucumber/parser/treetop_ext.rb +75 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/rails/rspec.rb +5 -2
- data/lib/cucumber/step_definition.rb +87 -0
- data/lib/cucumber/step_mother.rb +151 -66
- data/lib/cucumber/version.rb +2 -2
- data/rails_generators/cucumber/USAGE +3 -2
- data/rails_generators/cucumber/cucumber_generator.rb +33 -23
- data/rails_generators/cucumber/templates/cucumber +2 -1
- data/rails_generators/cucumber/templates/cucumber.rake +6 -1
- data/rails_generators/cucumber/templates/env.rb +1 -1
- data/rails_generators/feature/USAGE +3 -0
- data/rails_generators/feature/feature_generator.rb +30 -6
- data/spec/cucumber/ast/background_spec.rb +58 -0
- data/spec/cucumber/ast/feature_factory.rb +54 -0
- data/spec/cucumber/ast/feature_spec.rb +60 -0
- data/spec/cucumber/ast/py_string_spec.rb +40 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
- data/spec/cucumber/ast/scenario_spec.rb +82 -0
- data/spec/cucumber/ast/step_spec.rb +45 -0
- data/spec/cucumber/ast/table_spec.rb +81 -0
- data/spec/cucumber/ast/tags_spec.rb +23 -0
- data/spec/cucumber/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli/configuration_spec.rb +239 -0
- data/spec/cucumber/cli/main_spec.rb +164 -0
- data/spec/cucumber/core_ext/proc_spec.rb +27 -35
- data/spec/cucumber/core_ext/string_spec.rb +8 -0
- data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/html/cucumber.css +37 -0
- data/spec/cucumber/formatter/html/cucumber.js +13 -0
- data/spec/cucumber/formatter/html/index.html +45 -0
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +281 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mother_spec.rb +50 -51
- data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
- data/spec/cucumber/treetop_parser/scenario_outline.feature +1 -1
- data/spec/cucumber/treetop_parser/spaces.feature +3 -1
- data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
- data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
- data/spec/cucumber/world/pending_spec.rb +13 -12
- data/spec/spec_helper.rb +1 -1
- metadata +107 -79
- data/examples/calculator_ruby_features/features/addition.rb +0 -39
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
- data/gem_tasks/treetop.rake +0 -41
- data/lib/cucumber/cli.rb +0 -355
- data/lib/cucumber/executor.rb +0 -205
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -23
- data/lib/cucumber/formatters/cucumber.css +0 -132
- data/lib/cucumber/formatters/cucumber.js +0 -11
- data/lib/cucumber/formatters/html_formatter.rb +0 -152
- data/lib/cucumber/formatters/jquery.js +0 -32
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
- data/lib/cucumber/formatters/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/step_methods.rb +0 -49
- data/lib/cucumber/tree.rb +0 -16
- data/lib/cucumber/tree/feature.rb +0 -105
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/given_scenario.rb +0 -13
- data/lib/cucumber/tree/scenario.rb +0 -240
- data/lib/cucumber/tree/step.rb +0 -173
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
- data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
- data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
- data/lib/cucumber/world.rb +0 -1
- data/lib/cucumber/world/pending.rb +0 -22
- data/setup.rb +0 -1585
- data/spec/cucumber/cli_spec.rb +0 -521
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -26
- data/spec/cucumber/formatters/features.html +0 -269
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -110
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
- data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
- data/spec/cucumber/model/table_spec.rb +0 -32
- data/spec/cucumber/tree/feature_spec.rb +0 -122
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
- data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
- data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
- data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
- data/spec/cucumber/tree/scenario_spec.rb +0 -134
- data/spec/cucumber/tree/step_outline_spec.rb +0 -17
- data/spec/cucumber/tree/step_spec.rb +0 -59
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
@@ -1,8 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/formatter/profile'
|
2
3
|
|
3
4
|
module Cucumber
|
4
|
-
module
|
5
|
-
describe
|
5
|
+
module Formatter
|
6
|
+
describe Progress do
|
6
7
|
attr_reader :io, :formatter
|
7
8
|
|
8
9
|
def mock_proc(stubs={})
|
@@ -23,20 +24,20 @@ module Cucumber
|
|
23
24
|
::Term::ANSIColor.coloring = false
|
24
25
|
@io = StringIO.new
|
25
26
|
step_mother = stub('step_mother')
|
26
|
-
@formatter = ProfileFormatter.new(
|
27
|
+
@formatter = ProfileFormatter.new(step_mother, io)
|
27
28
|
end
|
28
29
|
|
29
30
|
after(:each) do
|
30
31
|
::Term::ANSIColor.coloring = true
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
+
xit "should print a heading" do
|
34
35
|
formatter.visit_features(nil)
|
35
36
|
|
36
37
|
io.string.should eql("Profiling enabled.\n")
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
xit "should record the current time when starting a new step" do
|
40
41
|
now = Time.now
|
41
42
|
Time.stub!(:now).and_return(now)
|
42
43
|
formatter.step_executing('should foo', nil, nil)
|
@@ -52,7 +53,7 @@ module Cucumber
|
|
52
53
|
Time.stub!(:now).and_return(now, now)
|
53
54
|
end
|
54
55
|
|
55
|
-
|
56
|
+
xit "should group by regular expressions and actual keyword" do
|
56
57
|
step_1 = mock_step(:actual_keyword => 'Given')
|
57
58
|
step_2 = mock_step(:actual_keyword => 'Given')
|
58
59
|
|
@@ -65,7 +66,7 @@ module Cucumber
|
|
65
66
|
step_times.has_key?('Given /ichiban/').should be_true
|
66
67
|
end
|
67
68
|
|
68
|
-
|
69
|
+
xit "should use a previous step's keyword when recording row steps" do
|
69
70
|
step = mock_step(:actual_keyword => 'Given')
|
70
71
|
step_row = mock_step(:row? => true)
|
71
72
|
|
@@ -79,7 +80,7 @@ module Cucumber
|
|
79
80
|
|
80
81
|
end
|
81
82
|
|
82
|
-
|
83
|
+
xit "should correctly record a passed step" do
|
83
84
|
formatter.step_executing(nil, nil, nil)
|
84
85
|
formatter.step_passed(mock_step(:format => 'she doth teach the torches to burn bright', :actual_keyword => 'Given'), nil, nil)
|
85
86
|
formatter.dump
|
@@ -87,7 +88,7 @@ module Cucumber
|
|
87
88
|
io.string.should include('Given she doth teach the torches to burn bright')
|
88
89
|
end
|
89
90
|
|
90
|
-
|
91
|
+
xit "should correctly record a passed step row" do
|
91
92
|
formatter.step_executing(nil, nil, nil)
|
92
93
|
formatter.step_passed(mock_step(:row? => true), /example/, ['fitty'])
|
93
94
|
formatter.dump
|
@@ -95,7 +96,7 @@ module Cucumber
|
|
95
96
|
io.string.should include('fitty')
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
|
+
xit "should calculate the mean step execution time" do
|
99
100
|
now = Time.now
|
100
101
|
Time.stub!(:now).and_return(now, now+5, now, now+1)
|
101
102
|
|
@@ -109,7 +110,7 @@ module Cucumber
|
|
109
110
|
io.string.should include('3.0000000')
|
110
111
|
end
|
111
112
|
|
112
|
-
|
113
|
+
xit "should display file and line comment for step invocation" do
|
113
114
|
step = mock_step(:format => 'test', :actual_keyword => 'Given', :file => 'test.feature', :line => 5)
|
114
115
|
|
115
116
|
formatter.step_executing(step, nil, nil)
|
@@ -119,7 +120,7 @@ module Cucumber
|
|
119
120
|
@io.string.should include("# test.feature:5")
|
120
121
|
end
|
121
122
|
|
122
|
-
|
123
|
+
xit "should display file and line comment for step definition" do
|
123
124
|
step = mock_step(:format => 'test', :actual_keyword => 'Given',
|
124
125
|
:regexp_args_proc => [/test/, nil, mock_proc(:to_comment_line => '# steps/example_steps.rb:11')])
|
125
126
|
|
@@ -130,7 +131,7 @@ module Cucumber
|
|
130
131
|
@io.string.should include("# steps/example_steps.rb:11")
|
131
132
|
end
|
132
133
|
|
133
|
-
|
134
|
+
xit "should show the performance times of the step invocations for a step definition" do
|
134
135
|
now = Time.now
|
135
136
|
Time.stub!(:now).and_return(now, now+5, now, now+1)
|
136
137
|
|
@@ -148,7 +149,7 @@ module Cucumber
|
|
148
149
|
io.string.should include("1.0000000 Given step invocation")
|
149
150
|
end
|
150
151
|
|
151
|
-
|
152
|
+
xit "should sort the step invocations in descending order" do
|
152
153
|
now = Time.now
|
153
154
|
Time.stub!(:now).and_return(now, now+1, now, now+5)
|
154
155
|
|
@@ -166,7 +167,7 @@ module Cucumber
|
|
166
167
|
io_string_lines.at(-1).should include('1.0000000')
|
167
168
|
end
|
168
169
|
|
169
|
-
|
170
|
+
xit "should print the top average 10 step results" do
|
170
171
|
formatter.instance_variable_set("@step_time", Time.now)
|
171
172
|
|
172
173
|
11.times do |test_number|
|
@@ -180,7 +181,7 @@ module Cucumber
|
|
180
181
|
io.string.scan(/unique_test_\d+/).length.should == 10
|
181
182
|
end
|
182
183
|
|
183
|
-
|
184
|
+
xit "should print the top 5 step invocations for step definition" do
|
184
185
|
formatter.instance_variable_set("@step_time", Time.now)
|
185
186
|
|
186
187
|
10.times do |test_number|
|
@@ -0,0 +1,281 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/parser'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Parser
|
6
|
+
describe Feature do
|
7
|
+
before do
|
8
|
+
@parser = FeatureParser.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse(text)
|
12
|
+
feature = @parser.parse_or_fail(text)
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_file(file)
|
16
|
+
@parser.parse_file(File.dirname(__FILE__) + "/../treetop_parser/" + file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def parse_example_file(file)
|
20
|
+
@parser.parse_file(File.dirname(__FILE__) + "/../../../examples/" + file)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Header" do
|
24
|
+
it "should parse Feature with blurb" do
|
25
|
+
parse(%{Feature: hi
|
26
|
+
with blurb
|
27
|
+
})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Comments" do
|
32
|
+
it "should parse a file with only a one line comment" do
|
33
|
+
parse(%{# My comment
|
34
|
+
Feature: hi
|
35
|
+
}).to_sexp.should ==
|
36
|
+
[:feature, "Feature: hi\n",
|
37
|
+
[:comment, "# My comment\n"]]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse a comment within a scenario" do
|
41
|
+
pending "Store comment in node and output it in pretty formatter"
|
42
|
+
parse(%{Feature: Hi
|
43
|
+
Scenario: Hello
|
44
|
+
Given foo
|
45
|
+
# When bar
|
46
|
+
Then baz
|
47
|
+
}).to_sexp.should ==
|
48
|
+
[:feature, "Feature: Hi",
|
49
|
+
[:scenario, 2, "Scenario:", "Hello",
|
50
|
+
[:step, 3, "Given", "foo"],
|
51
|
+
[:comment, "# When bar\n"],
|
52
|
+
[:step, 5, "Then", "baz"]
|
53
|
+
]
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should parse a file with only a multiline comment" do
|
58
|
+
parse(%{# Hello
|
59
|
+
# World
|
60
|
+
Feature: hi
|
61
|
+
}).to_sexp.should ==
|
62
|
+
[:feature, "Feature: hi\n",
|
63
|
+
[:comment, "# Hello\n# World\n"]]
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should parse a file with no comments" do
|
67
|
+
parse("Feature: hi\n").to_sexp.should ==
|
68
|
+
[:feature, "Feature: hi\n"]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should parse a file with only a multiline comment with newlines" do
|
72
|
+
parse("# Hello\n\n# World\n").to_sexp.should ==
|
73
|
+
[:feature, "",
|
74
|
+
[:comment, "# Hello\n\n# World\n"]]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "Tags" do
|
79
|
+
it "should parse a file with tags on a feature" do
|
80
|
+
parse("# My comment\n@hello @world Feature: hi\n").to_sexp.should ==
|
81
|
+
[:feature, "Feature: hi\n",
|
82
|
+
[:comment, "# My comment\n"],
|
83
|
+
[:tag, "hello"],
|
84
|
+
[:tag, "world"]]
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should parse a file with tags on a scenario" do
|
88
|
+
parse(%{# FC
|
89
|
+
@ft
|
90
|
+
Feature: hi
|
91
|
+
|
92
|
+
@st1 @st2
|
93
|
+
Scenario: First
|
94
|
+
Given Pepper
|
95
|
+
|
96
|
+
@st3
|
97
|
+
@st4
|
98
|
+
Scenario: Second}).to_sexp.should ==
|
99
|
+
[:feature, "Feature: hi",
|
100
|
+
[:comment, "# FC\n "],
|
101
|
+
[:tag, "ft"],
|
102
|
+
[:scenario, 6, 'Scenario:', 'First',
|
103
|
+
[:tag, "st1"], [:tag, "st2"],
|
104
|
+
[:step, 7, "Given", "Pepper"]],
|
105
|
+
[:scenario, 11, 'Scenario:', 'Second',
|
106
|
+
[:tag, "st3"], [:tag, "st4"]]]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "Background" do
|
111
|
+
it "should have steps" do
|
112
|
+
parse("Feature: Hi\nBackground:\nGiven I am a step\n").to_sexp.should ==
|
113
|
+
[:feature, "Feature: Hi",
|
114
|
+
[:background, 2, "Background:",
|
115
|
+
[:step, 3, "Given", "I am a step"]]]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "Scenarios" do
|
120
|
+
it "can be empty" do
|
121
|
+
parse("Feature: Hi\n\nScenario: Hello\n").to_sexp.should ==
|
122
|
+
[:feature, "Feature: Hi",
|
123
|
+
[:scenario, 3, "Scenario:", "Hello"]]
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should allow whitespace lines after the Scenario line" do
|
127
|
+
parse(%{Feature: Foo
|
128
|
+
|
129
|
+
Scenario: bar
|
130
|
+
|
131
|
+
Given baz})
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should have steps" do
|
135
|
+
parse("Feature: Hi\nScenario: Hello\nGiven I am a step\n").to_sexp.should ==
|
136
|
+
[:feature, "Feature: Hi",
|
137
|
+
[:scenario, 2, "Scenario:", "Hello",
|
138
|
+
[:step, 3, "Given", "I am a step"]]]
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should have steps with inline table" do
|
142
|
+
parse(%{Feature: Hi
|
143
|
+
Scenario: Hello
|
144
|
+
Given I have a table
|
145
|
+
|a|b|
|
146
|
+
}).to_sexp.should ==
|
147
|
+
[:feature, "Feature: Hi",
|
148
|
+
[:scenario, 2, "Scenario:", "Hello",
|
149
|
+
[:step, 3, "Given", "I have a table",
|
150
|
+
[:table,
|
151
|
+
[:row,
|
152
|
+
[:cell, "a"],
|
153
|
+
[:cell, "b"]]]]]]
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should have steps with inline py_string" do
|
157
|
+
parse(%{Feature: Hi
|
158
|
+
Scenario: Hello
|
159
|
+
Given I have a string
|
160
|
+
|
161
|
+
|
162
|
+
"""
|
163
|
+
hello
|
164
|
+
world
|
165
|
+
"""
|
166
|
+
|
167
|
+
}).to_sexp.should ==
|
168
|
+
[:feature, "Feature: Hi",
|
169
|
+
[:scenario, 2, "Scenario:", "Hello",
|
170
|
+
[:step, 3, "Given", "I have a string",
|
171
|
+
[:py_string, "hello\nworld"]]]]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "Scenario Outlines" do
|
176
|
+
it "can be empty" do
|
177
|
+
parse(%{Feature: Hi
|
178
|
+
Scenario Outline: Hello
|
179
|
+
Given a <what> cucumber
|
180
|
+
Examples:
|
181
|
+
|what|
|
182
|
+
|green|
|
183
|
+
}).to_sexp.should ==
|
184
|
+
[:feature, "Feature: Hi",
|
185
|
+
[:scenario_outline, "Scenario Outline:", "Hello",
|
186
|
+
[:step, 3, "Given", "a <what> cucumber"],
|
187
|
+
[:examples, "Examples:", "",
|
188
|
+
[:table,
|
189
|
+
[:row,
|
190
|
+
[:cell, "what"]],
|
191
|
+
[:row, [:cell, "green"]]]]]]
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should have line numbered steps with inline table" do
|
195
|
+
parse(%{Feature: Hi
|
196
|
+
Scenario Outline: Hello
|
197
|
+
|
198
|
+
Given I have a table
|
199
|
+
|
200
|
+
|<a>|<b>|
|
201
|
+
Examples:
|
202
|
+
|a|b|
|
203
|
+
|c|d|
|
204
|
+
}).to_sexp.should ==
|
205
|
+
[:feature, "Feature: Hi",
|
206
|
+
[:scenario_outline, "Scenario Outline:", "Hello",
|
207
|
+
[:step, 4, "Given", "I have a table",
|
208
|
+
[:table,
|
209
|
+
[:row,
|
210
|
+
[:cell, "<a>"],
|
211
|
+
[:cell, "<b>"]]]],
|
212
|
+
[:examples, "Examples:", "",
|
213
|
+
[:table,
|
214
|
+
[:row,
|
215
|
+
[:cell, "a"],
|
216
|
+
[:cell, "b"]],
|
217
|
+
[:row,
|
218
|
+
[:cell, "c"],
|
219
|
+
[:cell, "d"]]]]]]
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should have examples" do
|
223
|
+
parse("Feature: Hi
|
224
|
+
|
225
|
+
Scenario Outline: Hello
|
226
|
+
|
227
|
+
Given I have a table
|
228
|
+
|1|2|
|
229
|
+
|
230
|
+
Examples:
|
231
|
+
|x|y|
|
232
|
+
|5|6|
|
233
|
+
|
234
|
+
").to_sexp.should ==
|
235
|
+
[:feature, "Feature: Hi",
|
236
|
+
[:scenario_outline, "Scenario Outline:", "Hello",
|
237
|
+
[:step, 5, "Given", "I have a table",
|
238
|
+
[:table,
|
239
|
+
[:row,
|
240
|
+
[:cell, "1"],
|
241
|
+
[:cell, "2"]]]],
|
242
|
+
[:examples, "Examples:", "",
|
243
|
+
[:table,
|
244
|
+
[:row,
|
245
|
+
[:cell, "x"],
|
246
|
+
[:cell, "y"]],
|
247
|
+
[:row,
|
248
|
+
[:cell, "5"],
|
249
|
+
[:cell, "6"]]]]]]
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should set line numbers on feature" do
|
253
|
+
feature = parse_file("empty_feature.feature:11:12")
|
254
|
+
feature.instance_variable_get('@lines').should == [11, 12]
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe "Syntax" do
|
259
|
+
it "should parse empty_feature" do
|
260
|
+
parse_file("empty_feature.feature")
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should parse empty_scenario" do
|
264
|
+
parse_file("empty_scenario.feature")
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should parse empty_scenario_outline" do
|
268
|
+
parse_file("empty_scenario_outline.feature")
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should parse fit_scenario" do
|
272
|
+
parse_file("multiline_steps.feature")
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should parse scenario_outline" do
|
276
|
+
parse_file("scenario_outline.feature")
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'treetop'
|
3
|
+
require 'cucumber/parser'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Parser
|
7
|
+
describe 'Tables' do
|
8
|
+
before do
|
9
|
+
@parser = FeatureParser.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse(text)
|
13
|
+
@parser.__send__(:prepare_to_parse, text)
|
14
|
+
@parser.root = :table
|
15
|
+
table = @parser._nt_table
|
16
|
+
table.raw
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse a 1x2 table with newline" do
|
20
|
+
parse(" | 1 | 2 | \n").should == [%w{1 2}]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse a 1x2 table without newline" do
|
24
|
+
parse("| 1 | 2 |").should == [%w{1 2}]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should parse a 1x2 table without spaces" do
|
28
|
+
parse("|1|2|").should == [%w{1 2}]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should parse a 2x2 table" do
|
32
|
+
parse("| 1 | 2 |\n| 3 | 4 |\n").should == [%w{1 2}, %w{3 4}]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should parse a 2x2 table with several newlines" do
|
36
|
+
parse("| 1 | 2 |\n| 3 | 4 |\n\n\n").should == [%w{1 2}, %w{3 4}]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should parse a 2x2 table with empty cells" do
|
40
|
+
parse("| 1 | |\n|| 4 |\n").should == [['1', nil], [nil, '4']]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not parse a 2x2 table that isn't closed" do
|
44
|
+
parse("| 1 | |\n|| 4 ").should_not == [['1', nil], [nil, '4']]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|