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,154 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/test/action'
3
- require 'cucumber/core/test/duration_matcher'
4
-
5
- module Cucumber
6
- module Core
7
- module Test
8
-
9
- describe Action do
10
-
11
- context "constructed without a block" do
12
- it "raises an error" do
13
- expect { Action.new }.to raise_error(ArgumentError)
14
- end
15
- end
16
-
17
- context "location" do
18
-
19
- context "with location passed to the constructor" do
20
- let(:location) { double }
21
-
22
- it "returns the location passed to the constructor" do
23
- action = Action.new(location) {}
24
- expect( action.location ).to be location
25
- end
26
- end
27
-
28
- context "without location passed to the constructor" do
29
- let(:block) { proc {} }
30
-
31
- it "returns the location of the block passed to the constructor" do
32
- action = Action.new(&block)
33
- expect( action.location ).to eq Ast::Location.new(*block.source_location)
34
- end
35
- end
36
-
37
- end
38
-
39
- context "executing" do
40
- it "executes the block passed to the constructor" do
41
- executed = false
42
- action = Action.new { executed = true }
43
- action.execute
44
- expect( executed ).to be_truthy
45
- end
46
-
47
- it "returns a passed result if the block doesn't fail" do
48
- action = Action.new {}
49
- expect( action.execute ).to be_passed
50
- end
51
-
52
- it "returns a failed result when the block raises an error" do
53
- exception = StandardError.new
54
- action = Action.new { raise exception }
55
- result = action.execute
56
- expect( result ).to be_failed
57
- expect( result.exception ).to eq exception
58
- end
59
-
60
- it "yields the args passed to #execute to the block" do
61
- args = [double, double]
62
- args_spy = nil
63
- action = Action.new { |arg1, arg2| args_spy = [arg1, arg2] }
64
- action.execute(*args)
65
- expect(args_spy).to eq args
66
- end
67
-
68
- it "returns a pending result if a Result::Pending error is raised" do
69
- exception = Result::Pending.new("TODO")
70
- action = Action.new { raise exception }
71
- result = action.execute
72
- expect( result ).to be_pending
73
- expect( result.message ).to eq "TODO"
74
- end
75
-
76
- it "returns a skipped result if a Result::Skipped error is raised" do
77
- exception = Result::Skipped.new("Not working right now")
78
- action = Action.new { raise exception }
79
- result = action.execute
80
- expect( result ).to be_skipped
81
- expect( result.message ).to eq "Not working right now"
82
- end
83
-
84
- it "returns an undefined result if a Result::Undefined error is raised" do
85
- exception = Result::Undefined.new("new step")
86
- action = Action.new { raise exception }
87
- result = action.execute
88
- expect( result ).to be_undefined
89
- expect( result.message ).to eq "new step"
90
- end
91
-
92
- context "recording the duration" do
93
- before do
94
- allow( Timer::MonotonicTime ).to receive(:time_in_nanoseconds).and_return(525702744080000, 525702744080001)
95
- end
96
-
97
- it "records the nanoseconds duration of the execution on the result" do
98
- action = Action.new { }
99
- duration = action.execute.duration
100
- expect( duration ).to be_duration 1
101
- end
102
-
103
- it "records the duration of a failed execution" do
104
- action = Action.new { raise StandardError }
105
- duration = action.execute.duration
106
- expect( duration ).to be_duration 1
107
- end
108
- end
109
-
110
- end
111
-
112
- context "skipping" do
113
- it "does not execute the block" do
114
- executed = false
115
- action = Action.new { executed = true }
116
- action.skip
117
- expect( executed ).to be_falsey
118
- end
119
-
120
- it "returns a skipped result" do
121
- action = Action.new {}
122
- expect( action.skip ).to be_skipped
123
- end
124
- end
125
- end
126
-
127
- describe UndefinedAction do
128
- let(:location) { double }
129
- let(:action) { UndefinedAction.new(location) }
130
- let(:test_step) { double }
131
-
132
- context "location" do
133
- it "returns the location passed to the constructor" do
134
- expect( action.location ).to be location
135
- end
136
- end
137
-
138
- context "executing" do
139
- it "returns an undefined result" do
140
- expect( action.execute ).to be_undefined
141
- end
142
- end
143
-
144
- context "skipping" do
145
- it "returns an undefined result" do
146
- expect( action.skip ).to be_undefined
147
- end
148
- end
149
- end
150
-
151
- end
152
- end
153
- end
154
-
@@ -1,316 +0,0 @@
1
- # frozen_string_literal: true
2
- # -*- coding: utf-8 -*-
3
- require 'cucumber/core'
4
- require 'cucumber/core/gherkin/writer'
5
- require 'cucumber/core/platform'
6
- require 'cucumber/core/test/case'
7
- require 'unindent'
8
-
9
- module Cucumber
10
- module Core
11
- module Test
12
- describe Case do
13
- include Core
14
- include Core::Gherkin::Writer
15
-
16
- let(:test_case) { Test::Case.new(test_steps, [feature, scenario]) }
17
- let(:feature) { double(location: "features/test.feature:1") }
18
- let(:scenario) { double(location: "features/test.feature:2") }
19
- let(:test_steps) { [double, double] }
20
-
21
- context 'describing itself' do
22
- it "describes itself to a visitor" do
23
- visitor = double
24
- args = double
25
- expect( visitor ).to receive(:test_case).with(test_case, args)
26
- test_case.describe_to(visitor, args)
27
- end
28
-
29
- it "asks each test_step to describe themselves to the visitor" do
30
- visitor = double
31
- args = double
32
- test_steps.each do |test_step|
33
- expect( test_step ).to receive(:describe_to).with(visitor, args)
34
- end
35
- allow( visitor ).to receive(:test_case).and_yield(visitor)
36
- test_case.describe_to(visitor, args)
37
- end
38
-
39
- it "describes around hooks in order" do
40
- visitor = double
41
- allow( visitor ).to receive(:test_case).and_yield(visitor)
42
- first_hook, second_hook = double, double
43
- expect( first_hook ).to receive(:describe_to).ordered.and_yield
44
- expect( second_hook ).to receive(:describe_to).ordered.and_yield
45
- around_hooks = [first_hook, second_hook]
46
- Test::Case.new([], [], around_hooks).describe_to(visitor, double)
47
- end
48
-
49
- it "describes its source to a visitor" do
50
- visitor = double
51
- args = double
52
- expect( feature ).to receive(:describe_to).with(visitor, args)
53
- expect( scenario ).to receive(:describe_to).with(visitor, args)
54
- test_case.describe_source_to(visitor, args)
55
- end
56
-
57
- end
58
-
59
- describe "#name" do
60
- context "created from a scenario" do
61
- it "takes its name from the name of a scenario" do
62
- gherkin = gherkin do
63
- feature do
64
- scenario 'Scenario name' do
65
- step 'passing'
66
- end
67
- end
68
- end
69
- receiver = double.as_null_object
70
-
71
- expect( receiver ).to receive(:test_case) do |test_case|
72
- expect( test_case.name ).to eq 'Scenario name'
73
- expect( test_case.keyword ).to eq 'Scenario'
74
- end
75
- compile([gherkin], receiver)
76
- end
77
- end
78
-
79
- context "created from a scenario outline example" do
80
- it "takes its name from the name of the scenario outline and examples table" do
81
- gherkin = gherkin do
82
- feature do
83
- scenario_outline 'outline name' do
84
- step 'passing with arg'
85
-
86
- examples 'examples name' do
87
- row 'arg'
88
- row 'a'
89
- row 'b'
90
- end
91
-
92
- examples '' do
93
- row 'arg'
94
- row 'c'
95
- end
96
- end
97
- end
98
- end
99
- receiver = double.as_null_object
100
- expect( receiver ).to receive(:test_case) do |test_case|
101
- expect( test_case.name ).to eq 'outline name, examples name (#1)'
102
- expect( test_case.keyword ).to eq 'Scenario Outline'
103
- end.once.ordered
104
- expect( receiver ).to receive(:test_case) do |test_case|
105
- expect( test_case.name ).to eq 'outline name, examples name (#2)'
106
- end.once.ordered
107
- expect( receiver ).to receive(:test_case) do |test_case|
108
- expect( test_case.name ).to eq 'outline name, Examples (#1)'
109
- end.once.ordered
110
- compile [gherkin], receiver
111
- end
112
- end
113
- end
114
-
115
- describe "#location" do
116
- context "created from a scenario" do
117
- it "takes its location from the location of the scenario" do
118
- gherkin = gherkin('features/foo.feature') do
119
- feature do
120
- scenario do
121
- step
122
- end
123
- end
124
- end
125
- receiver = double.as_null_object
126
- expect( receiver ).to receive(:test_case) do |test_case|
127
- expect( test_case.location.to_s ).to eq 'features/foo.feature:3'
128
- end
129
- compile([gherkin], receiver)
130
- end
131
- end
132
-
133
- context "created from a scenario outline example" do
134
- it "takes its location from the location of the scenario outline example row" do
135
- gherkin = gherkin('features/foo.feature') do
136
- feature do
137
- scenario_outline do
138
- step 'passing with arg'
139
-
140
- examples do
141
- row 'arg'
142
- row '1'
143
- row '2'
144
- end
145
- end
146
- end
147
- end
148
- receiver = double.as_null_object
149
- expect( receiver ).to receive(:test_case) do |test_case|
150
- expect( test_case.location.to_s ).to eq 'features/foo.feature:8'
151
- end.once.ordered
152
- expect( receiver ).to receive(:test_case) do |test_case|
153
- expect( test_case.location.to_s ).to eq 'features/foo.feature:9'
154
- end.once.ordered
155
- compile [gherkin], receiver
156
- end
157
- end
158
- end
159
-
160
- describe "#tags" do
161
- it "includes all tags from the parent feature" do
162
- gherkin = gherkin do
163
- feature tags: ['@a', '@b'] do
164
- scenario tags: ['@c'] do
165
- step
166
- end
167
- scenario_outline tags: ['@d'] do
168
- step 'passing with arg'
169
- examples tags: ['@e'] do
170
- row 'arg'
171
- row 'x'
172
- end
173
- end
174
- end
175
- end
176
- receiver = double.as_null_object
177
- expect( receiver ).to receive(:test_case) do |test_case|
178
- expect( test_case.tags.map(&:name) ).to eq ['@a', '@b', '@c']
179
- end.once.ordered
180
- expect( receiver ).to receive(:test_case) do |test_case|
181
- expect( test_case.tags.map(&:name) ).to eq ['@a', '@b', '@d', '@e']
182
- end.once.ordered
183
- compile [gherkin], receiver
184
- end
185
- end
186
-
187
- describe "matching tags" do
188
- it "matches tags using tag expressions" do
189
- gherkin = gherkin do
190
- feature tags: ['@a', '@b'] do
191
- scenario tags: ['@c'] do
192
- step
193
- end
194
- end
195
- end
196
- receiver = double.as_null_object
197
- expect( receiver ).to receive(:test_case) do |test_case|
198
- expect( test_case.match_tags?(['@a and @b']) ).to be_truthy
199
- expect( test_case.match_tags?(['@a or @d']) ).to be_truthy
200
- expect( test_case.match_tags?(['not @d']) ).to be_truthy
201
- expect( test_case.match_tags?(['@a and @d']) ).to be_falsy
202
- end
203
- compile [gherkin], receiver
204
- end
205
-
206
- it "matches handles multiple expressions" do
207
- gherkin = gherkin do
208
- feature tags: ['@a', '@b'] do
209
- scenario tags: ['@c'] do
210
- step
211
- end
212
- end
213
- end
214
- receiver = double.as_null_object
215
- expect( receiver ).to receive(:test_case) do |test_case|
216
- expect( test_case.match_tags?(['@a and @b', 'not @d']) ).to be_truthy
217
- expect( test_case.match_tags?(['@a and @b', 'not @c']) ).to be_falsy
218
- end
219
- compile [gherkin], receiver
220
- end
221
- end
222
-
223
- describe "matching tags (old style)" do
224
- it "matches boolean expressions of tags" do
225
- gherkin = gherkin do
226
- feature tags: ['@a', '@b'] do
227
- scenario tags: ['@c'] do
228
- step
229
- end
230
- end
231
- end
232
- receiver = double.as_null_object
233
- expect( receiver ).to receive(:test_case) do |test_case|
234
- expect( test_case.match_tags?(['@a', '@b']) ).to be_truthy
235
- expect( test_case.match_tags?(['@a, @d']) ).to be_truthy
236
- expect( test_case.match_tags?(['~@d']) ).to be_truthy
237
- expect( test_case.match_tags?(['@a', '@d']) ).to be_falsy
238
- end
239
- compile [gherkin], receiver
240
- end
241
-
242
- it "handles mixing old and new style expressions" do
243
- gherkin = gherkin do
244
- feature tags: ['@a', '@b'] do
245
- scenario tags: ['@c'] do
246
- step
247
- end
248
- end
249
- end
250
- receiver = double.as_null_object
251
- expect( receiver ).to receive(:test_case) do |test_case|
252
- expect( test_case.match_tags?(['@a and @b', '~@d']) ).to be_truthy
253
- end
254
- compile [gherkin], receiver
255
- end
256
- end
257
-
258
- describe "matching names" do
259
- it "matches names against regexp" do
260
- gherkin = gherkin do
261
- feature 'first feature' do
262
- scenario 'scenario' do
263
- step 'missing'
264
- end
265
- end
266
- end
267
- receiver = double.as_null_object
268
- expect( receiver ).to receive(:test_case) do |test_case|
269
- expect( test_case.match_name?(/feature/) ).to be_truthy
270
- end
271
- compile [gherkin], receiver
272
- end
273
- end
274
-
275
- describe "#language" do
276
- it 'takes its language from the feature' do
277
- gherkin = Gherkin::Document.new('features/treasure.feature', %{# language: en-pirate
278
- Ahoy matey!: Treasure map
279
- Heave to: Find the treasure
280
- Gangway! a map
281
- })
282
- receiver = double.as_null_object
283
- expect( receiver ).to receive(:test_case) do |test_case|
284
- expect( test_case.language.iso_code ).to eq 'en-pirate'
285
- end
286
- compile([gherkin], receiver)
287
- end
288
- end
289
-
290
- describe "equality" do
291
- it "is equal to another test case at the same location" do
292
- gherkin = gherkin('features/foo.feature') do
293
- feature do
294
- scenario do
295
- step
296
- end
297
- end
298
- end
299
- test_case_instances = []
300
- receiver = double.as_null_object
301
- allow(receiver).to receive(:test_case) do |test_case|
302
- test_case_instances << test_case
303
- end
304
- 2.times { compile([gherkin], receiver) }
305
- expect(test_case_instances.length).to eq 2
306
- expect(test_case_instances.uniq.length).to eq 1
307
- expect(test_case_instances[0]).to be_eql test_case_instances[1]
308
- expect(test_case_instances[0]).to eq test_case_instances[1]
309
- expect(test_case_instances[0]).not_to equal test_case_instances[1]
310
- end
311
- end
312
-
313
- end
314
- end
315
- end
316
- end