cucumber-core 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cucumber/core/version.rb +1 -1
  3. metadata +19 -85
  4. data/.coveralls.yml +0 -1
  5. data/.github/ISSUE_TEMPLATE.md +0 -48
  6. data/.github/PULL_REQUEST_TEMPLATE.md +0 -39
  7. data/.rspec +0 -1
  8. data/.ruby-gemset +0 -1
  9. data/.travis.yml +0 -30
  10. data/.yardopts +0 -6
  11. data/Gemfile +0 -2
  12. data/Rakefile +0 -28
  13. data/cucumber-core.gemspec +0 -36
  14. data/spec/capture_warnings.rb +0 -74
  15. data/spec/coverage.rb +0 -11
  16. data/spec/cucumber/core/ast/background_spec.rb +0 -11
  17. data/spec/cucumber/core/ast/data_table_spec.rb +0 -81
  18. data/spec/cucumber/core/ast/doc_string_spec.rb +0 -114
  19. data/spec/cucumber/core/ast/empty_multiline_argument_spec.rb +0 -28
  20. data/spec/cucumber/core/ast/examples_table_spec.rb +0 -113
  21. data/spec/cucumber/core/ast/location_spec.rb +0 -199
  22. data/spec/cucumber/core/ast/outline_step_spec.rb +0 -93
  23. data/spec/cucumber/core/ast/step_spec.rb +0 -174
  24. data/spec/cucumber/core/compiler_spec.rb +0 -267
  25. data/spec/cucumber/core/event_bus_spec.rb +0 -163
  26. data/spec/cucumber/core/event_spec.rb +0 -40
  27. data/spec/cucumber/core/filter_spec.rb +0 -101
  28. data/spec/cucumber/core/gherkin/parser_spec.rb +0 -261
  29. data/spec/cucumber/core/gherkin/writer_spec.rb +0 -333
  30. data/spec/cucumber/core/report/summary_spec.rb +0 -175
  31. data/spec/cucumber/core/test/action_spec.rb +0 -154
  32. data/spec/cucumber/core/test/case_spec.rb +0 -316
  33. data/spec/cucumber/core/test/duration_matcher.rb +0 -20
  34. data/spec/cucumber/core/test/filters/locations_filter_spec.rb +0 -405
  35. data/spec/cucumber/core/test/result_spec.rb +0 -474
  36. data/spec/cucumber/core/test/runner_spec.rb +0 -310
  37. data/spec/cucumber/core/test/step_spec.rb +0 -98
  38. data/spec/cucumber/core/test/timer_spec.rb +0 -25
  39. data/spec/cucumber/core_spec.rb +0 -262
  40. data/spec/readme_spec.rb +0 -37
  41. data/spec/report_api_spy.rb +0 -25
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/ast/outline_step'
3
- require 'cucumber/core/ast/examples_table'
4
- require 'cucumber/core/ast/data_table'
5
- require 'cucumber/core/ast/doc_string'
6
- require 'cucumber/core/ast/empty_multiline_argument'
7
-
8
- module Cucumber
9
- module Core
10
- module Ast
11
- describe OutlineStep do
12
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, multiline_arg) }
13
- let(:language) { double }
14
- let(:location) { double }
15
- let(:comments) { double }
16
- let(:keyword) { double }
17
- let(:text) { 'anything' }
18
- let(:multiline_arg) { EmptyMultilineArgument.new }
19
-
20
- describe 'location' do
21
- it "has a location" do
22
- expect( outline_step ).to respond_to(:location)
23
- end
24
-
25
- it 'knows the file and line' do
26
- allow( location ).to receive(:to_s) { 'file_name:8' }
27
- expect( outline_step.file_colon_line ).to eq 'file_name:8'
28
- end
29
- end
30
-
31
- describe "to_s" do
32
- it "returns the text of the step" do
33
- expect(outline_step.to_s).to eq 'anything'
34
- end
35
- end
36
-
37
- describe 'comments' do
38
- it "has comments" do
39
- expect( outline_step ).to respond_to(:comments)
40
- end
41
- end
42
-
43
- describe "converting to a Step" do
44
- context "a single argument in the name" do
45
- let(:text) { 'a <color> cucumber' }
46
-
47
- it "replaces the argument" do
48
- row = ExamplesTable::Row.new({'color' => 'green'}, 1, location, language, comments)
49
- expect( outline_step.to_step(row).text ).to eq 'a green cucumber'
50
- end
51
-
52
- end
53
-
54
- context "when the step has a DataTable" do
55
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, table) }
56
- let(:text) { "anything" }
57
- let(:table) { DataTable.new([['x', 'y'],['a', 'a <arg>']], Location.new('foo.feature', 23)) }
58
-
59
- it "replaces the arguments in the DataTable" do
60
- visitor = double
61
- allow( visitor ).to receive(:step).and_yield(visitor)
62
- expect( visitor ).to receive(:data_table) do |data_table|
63
- expect( data_table.raw ).to eq [['x', 'y'], ['a', 'a replacement']]
64
- end
65
- row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
66
- step = outline_step.to_step(row)
67
- step.describe_to(visitor)
68
- end
69
- end
70
-
71
- context "when the step has a DocString" do
72
- let(:location) { double }
73
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, doc_string) }
74
- let(:doc_string) { DocString.new('a <arg> that needs replacing', '', location) }
75
- let(:text) { 'anything' }
76
-
77
- it "replaces the arguments in the DocString" do
78
- visitor = double
79
- allow( visitor ).to receive(:step).and_yield(visitor)
80
- expect( visitor ).to receive(:doc_string) do |doc_string|
81
- expect( doc_string.content ).to eq "a replacement that needs replacing"
82
- end
83
- row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
84
- step = outline_step.to_step(row)
85
- step.describe_to(visitor)
86
- end
87
- end
88
- end
89
- end
90
- end
91
- end
92
- end
93
-
@@ -1,174 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/ast/step'
3
- require 'cucumber/core/ast/outline_step'
4
- require 'cucumber/core/ast/empty_multiline_argument'
5
- require 'gherkin/dialect'
6
-
7
- module Cucumber
8
- module Core
9
- module Ast
10
- describe Step do
11
- let(:step) do
12
- text = "a passing step"
13
- keyword = "Given"
14
- language, location, comments = *double
15
- multiline_arg = EmptyMultilineArgument.new
16
- Step.new(language, location, comments, keyword, text, multiline_arg)
17
- end
18
-
19
- describe "to_s" do
20
- it("returns the text of the step") do
21
- expect(step.to_s).to eq("a passing step")
22
- end
23
- end
24
-
25
- describe "describing itself" do
26
- let(:visitor) { double }
27
-
28
- it "describes itself as a step" do
29
- expect( visitor ).to receive(:step).with(step)
30
- step.describe_to(visitor)
31
- end
32
-
33
- context "with no multiline argument" do
34
- it "does not try to describe any children" do
35
- allow( visitor ).to receive(:step).with(step).and_yield(visitor)
36
- step.describe_to(visitor)
37
- end
38
- end
39
-
40
- context "with a multiline argument" do
41
- let(:step) { Step.new(double, double, double, double, double, multiline_arg) }
42
- let(:multiline_arg) { double }
43
-
44
- it "tells its multiline argument to describe itself" do
45
- allow( visitor ).to receive(:step).with(step).and_yield(visitor)
46
- expect( multiline_arg ).to receive(:describe_to).with(visitor)
47
- step.describe_to(visitor)
48
- end
49
- end
50
-
51
- end
52
-
53
- describe 'comments' do
54
- it "has comments" do
55
- expect( step ).to respond_to(:comments)
56
- end
57
- end
58
-
59
- describe "backtrace line" do
60
- let(:step) { Step.new(double, "path/file.feature:10", double, "Given ", "this step passes", double) }
61
-
62
- it "knows how to form the backtrace line" do
63
- expect( step.backtrace_line ).to eq("path/file.feature:10:in `Given this step passes'")
64
- end
65
-
66
- end
67
-
68
- describe "actual keyword" do
69
- let(:language) { ::Gherkin::Dialect.for('en') }
70
-
71
- context "for keywords 'given', 'when' and 'then'" do
72
- let(:given_step) { Step.new(language, double, double, "Given ", double, double) }
73
- let(:when_step) { Step.new(language, double, double, "When ", double, double) }
74
- let(:then_step) { Step.new(language, double, double, "Then ", double, double) }
75
-
76
- it "returns the keyword itself" do
77
- expect( given_step.actual_keyword(nil) ).to eq("Given ")
78
- expect( when_step.actual_keyword(nil) ).to eq("When ")
79
- expect( then_step.actual_keyword(nil) ).to eq("Then ")
80
- end
81
- end
82
-
83
- context "for keyword 'and', 'but', and '*'" do
84
- let(:and_step) { Step.new(language, double, double, "And ", double, double) }
85
- let(:but_step) { Step.new(language, double, double, "But ", double, double) }
86
- let(:asterisk_step) { Step.new(language, double, double, "* ", double, double) }
87
-
88
- context "when the previous step keyword exist" do
89
- it "returns the previous step keyword" do
90
- expect( and_step.actual_keyword("Then ") ).to eq("Then ")
91
- expect( but_step.actual_keyword("Then ") ).to eq("Then ")
92
- expect( asterisk_step.actual_keyword("Then ") ).to eq("Then ")
93
- end
94
- end
95
-
96
- context "when the previous step keyword does not exist" do
97
- it "returns the 'given' keyword" do
98
- expect( and_step.actual_keyword(nil) ).to eq("Given ")
99
- expect( but_step.actual_keyword(nil) ).to eq("Given ")
100
- expect( asterisk_step.actual_keyword(nil) ).to eq("Given ")
101
- end
102
- end
103
-
104
- end
105
-
106
- context "for i18n languages" do
107
- let(:language) { ::Gherkin::Dialect.for('en-lol') }
108
- let(:and_step) { Step.new(language, double, double, "AN ", double, double) }
109
-
110
- it "returns the keyword in the correct language" do
111
- expect( and_step.actual_keyword(nil) ).to eq("I CAN HAZ ")
112
- end
113
- end
114
- end
115
- end
116
-
117
- describe ExpandedOutlineStep do
118
- let(:outline_step) { double }
119
- let(:step) do
120
- language, location, keyword, text = *double
121
- multiline_arg = EmptyMultilineArgument.new
122
- comments = []
123
- ExpandedOutlineStep.new(outline_step, language, location, comments, keyword, text, multiline_arg)
124
- end
125
-
126
- describe "describing itself" do
127
- let(:visitor) { double }
128
-
129
- it "describes itself as a step" do
130
- expect( visitor ).to receive(:step).with(step)
131
- step.describe_to(visitor)
132
- end
133
-
134
- context "with no multiline argument" do
135
- it "does not try to describe any children" do
136
- allow( visitor ).to receive(:step).with(step).and_yield(visitor)
137
- step.describe_to(visitor)
138
- end
139
- end
140
-
141
- context "with a multiline argument" do
142
- let(:step) { Step.new(double, double, double, double, double, multiline_arg) }
143
- let(:multiline_arg) { double }
144
-
145
- it "tells its multiline argument to describe itself" do
146
- allow( visitor ).to receive(:step).with(step).and_yield(visitor)
147
- expect( multiline_arg ).to receive(:describe_to).with(visitor)
148
- step.describe_to(visitor)
149
- end
150
- end
151
-
152
- end
153
-
154
- describe 'comments' do
155
- it "has comments" do
156
- expect( step ).to respond_to(:comments)
157
- end
158
- end
159
-
160
- describe "backtrace line" do
161
- let(:outline_step) { OutlineStep.new(double, "path/file.feature:5", double, "Given ", "this step <state>", double) }
162
- let(:step) { ExpandedOutlineStep.new(outline_step, double, "path/file.feature:10", double, "Given ", "this step passes", double) }
163
-
164
- it "includes the outline step in the backtrace line" do
165
- expect( step.backtrace_line ).to eq("path/file.feature:10:in `Given this step passes'\n" +
166
- "path/file.feature:5:in `Given this step <state>'")
167
- end
168
-
169
- end
170
- end
171
- end
172
- end
173
- end
174
-
@@ -1,267 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core'
3
- require 'cucumber/core/compiler'
4
- require 'cucumber/core/gherkin/writer'
5
-
6
- module Cucumber::Core
7
- describe Compiler do
8
- include Gherkin::Writer
9
- include Cucumber::Core
10
-
11
- def self.stubs(*names)
12
- names.each do |name|
13
- let(name) { double(name.to_s) }
14
- end
15
- end
16
-
17
- it "compiles a feature with a single scenario" do
18
- gherkin_documents = [
19
- gherkin do
20
- feature do
21
- scenario do
22
- step 'passing'
23
- end
24
- end
25
- end
26
- ]
27
- compile(gherkin_documents) do |visitor|
28
- expect( visitor ).to receive(:test_case).once.ordered.and_yield(visitor)
29
- expect( visitor ).to receive(:test_step).once.ordered
30
- expect( visitor ).to receive(:done).once.ordered
31
- end
32
- end
33
-
34
- it "compiles a feature with a background" do
35
- gherkin_documents = [
36
- gherkin do
37
- feature do
38
- background do
39
- step 'passing'
40
- end
41
-
42
- scenario do
43
- step 'passing'
44
- end
45
- end
46
- end
47
- ]
48
- compile(gherkin_documents) do |visitor|
49
- expect( visitor ).to receive(:test_case).once.ordered.and_yield(visitor)
50
- expect( visitor ).to receive(:test_step).exactly(2).times.ordered
51
- expect( visitor ).to receive(:done).once.ordered
52
- end
53
- end
54
-
55
- it "compiles multiple features" do
56
- gherkin_documents = [
57
- gherkin do
58
- feature do
59
- background do
60
- step 'passing'
61
- end
62
- scenario do
63
- step 'passing'
64
- end
65
- end
66
- end,
67
- gherkin do
68
- feature do
69
- background do
70
- step 'passing'
71
- end
72
- scenario do
73
- step 'passing'
74
- end
75
- end
76
- end
77
- ]
78
- compile(gherkin_documents) do |visitor|
79
- expect( visitor ).to receive(:test_case).once.ordered
80
- expect( visitor ).to receive(:test_step).twice.ordered
81
- expect( visitor ).to receive(:test_case).once.ordered
82
- expect( visitor ).to receive(:test_step).twice.ordered
83
- expect( visitor ).to receive(:done).once
84
- end
85
- end
86
-
87
- context "compiling scenario outlines" do
88
- it "compiles a scenario outline to test cases" do
89
- gherkin_documents = [
90
- gherkin do
91
- feature do
92
- background do
93
- step 'passing'
94
- end
95
-
96
- scenario_outline do
97
- step 'passing <arg>'
98
- step 'passing'
99
-
100
- examples 'examples 1' do
101
- row 'arg'
102
- row '1'
103
- row '2'
104
- end
105
-
106
- examples 'examples 2' do
107
- row 'arg'
108
- row 'a'
109
- end
110
- end
111
- end
112
- end
113
- ]
114
- compile(gherkin_documents) do |visitor|
115
- expect( visitor ).to receive(:test_case).exactly(3).times.and_yield(visitor)
116
- expect( visitor ).to receive(:test_step).exactly(9).times
117
- expect( visitor ).to receive(:done).once
118
- end
119
- end
120
-
121
- it 'replaces arguments correctly when generating test steps' do
122
- gherkin_documents = [
123
- gherkin do
124
- feature do
125
- scenario_outline do
126
- step 'passing <arg1> with <arg2>'
127
- step 'as well as <arg3>'
128
-
129
- examples do
130
- row 'arg1', 'arg2', 'arg3'
131
- row '1', '2', '3'
132
- end
133
- end
134
- end
135
- end
136
- ]
137
-
138
- compile(gherkin_documents) do |visitor|
139
- expect( visitor ).to receive(:test_step) do |test_step|
140
- visit_source(test_step) do |source_visitor|
141
- expect( source_visitor ).to receive(:step) do |step|
142
- expect(step.text).to eq 'passing 1 with 2'
143
- end
144
- end
145
- end.once.ordered
146
-
147
- expect( visitor ).to receive(:test_step) do |test_step|
148
- visit_source(test_step) do |source_visitor|
149
- expect( source_visitor ).to receive(:step) do |step|
150
- expect(step.text).to eq 'as well as 3'
151
- end
152
- end
153
- end.once.ordered
154
-
155
- expect( visitor ).to receive(:done).once.ordered
156
- end
157
- end
158
- end
159
-
160
- context 'empty scenarios' do
161
- it 'does not create test cases for them' do
162
- gherkin_documents = [
163
- gherkin do
164
- feature do
165
- scenario do
166
- end
167
- end
168
- end
169
- ]
170
- compile(gherkin_documents) do |visitor|
171
- expect( visitor ).to receive(:test_case).never
172
- expect( visitor ).to receive(:done).once.ordered
173
- end
174
- end
175
- end
176
-
177
- describe Compiler::FeatureCompiler do
178
- let(:receiver) { double('receiver') }
179
- let(:compiler) { Compiler::FeatureCompiler.new(receiver) }
180
-
181
- context "a scenario with a background" do
182
- stubs(:feature,
183
- :background,
184
- :background_step,
185
- :scenario,
186
- :scenario_step)
187
-
188
- it "sets the source correctly on the test steps" do
189
- expect( receiver ).to receive(:on_background_step).with(
190
- [feature, background, background_step]
191
- )
192
- expect( receiver ).to receive(:on_step).with(
193
- [feature, scenario, scenario_step]
194
- )
195
- expect( receiver ).to receive(:on_test_case).with(
196
- [feature, scenario]
197
- )
198
- compiler.feature(feature) do |f|
199
- f.background(background) do |b|
200
- b.step background_step
201
- end
202
- f.scenario(scenario) do |s|
203
- s.step scenario_step
204
- end
205
- end
206
- end
207
- end
208
-
209
- context "a scenario outline" do
210
- stubs(:feature,
211
- :background,
212
- :background_step,
213
- :scenario_outline,
214
- :outline_step,
215
- :examples_table_1,
216
- :examples_table_1_row_1,
217
- :outline_ast_step,
218
- :examples_table_2,
219
- :examples_table_2_row_1,
220
- )
221
-
222
- it "sets the source correctly on the test steps" do
223
- allow( outline_step ).to receive(:to_step) { outline_ast_step }
224
- expect( receiver ).to receive(:on_step).with(
225
- [feature, scenario_outline, examples_table_1, examples_table_1_row_1, outline_ast_step]
226
- ).ordered
227
- expect( receiver ).to receive(:on_test_case).with(
228
- [feature, scenario_outline, examples_table_1, examples_table_1_row_1]
229
- ).ordered
230
- expect( receiver ).to receive(:on_step).with(
231
- [feature, scenario_outline, examples_table_2, examples_table_2_row_1, outline_ast_step]
232
- ).ordered
233
- expect( receiver ).to receive(:on_test_case).with(
234
- [feature, scenario_outline, examples_table_2, examples_table_2_row_1]
235
- ).ordered
236
- compiler.feature(feature) do |f|
237
- f.scenario_outline(scenario_outline) do |o|
238
- o.outline_step outline_step
239
- o.examples_table(examples_table_1) do |t|
240
- t.examples_table_row(examples_table_1_row_1)
241
- end
242
- o.examples_table(examples_table_2) do |t|
243
- t.examples_table_row(examples_table_2_row_1)
244
- end
245
- end
246
- end
247
- end
248
- end
249
- end
250
-
251
- def visit_source(node)
252
- visitor = double.as_null_object
253
- yield visitor
254
- node.describe_source_to(visitor)
255
- end
256
-
257
- def compile(gherkin_documents)
258
- visitor = double
259
- allow( visitor ).to receive(:test_suite).and_yield(visitor)
260
- allow( visitor ).to receive(:test_case).and_yield(visitor)
261
- yield visitor
262
- super(gherkin_documents, visitor)
263
- end
264
-
265
- end
266
- end
267
-