cucumber-core 5.0.1 → 8.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -9
- data/CONTRIBUTING.md +3 -1
- data/README.md +1 -0
- data/lib/cucumber/core.rb +8 -6
- data/lib/cucumber/core/compiler.rb +34 -13
- data/lib/cucumber/core/event.rb +0 -2
- data/lib/cucumber/core/events.rb +25 -0
- data/lib/cucumber/core/gherkin/parser.rb +21 -10
- data/lib/cucumber/core/gherkin/writer.rb +30 -2
- data/lib/cucumber/core/test/case.rb +5 -4
- data/lib/cucumber/core/test/data_table.rb +5 -9
- data/lib/cucumber/core/test/doc_string.rb +3 -6
- data/lib/cucumber/core/test/result.rb +64 -3
- data/lib/cucumber/core/test/step.rb +6 -5
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/coverage.rb +2 -0
- data/spec/cucumber/core/compiler_spec.rb +66 -3
- data/spec/cucumber/core/gherkin/parser_spec.rb +68 -1
- data/spec/cucumber/core/test/case_spec.rb +3 -2
- data/spec/cucumber/core/test/data_table_spec.rb +10 -12
- data/spec/cucumber/core/test/doc_string_spec.rb +8 -11
- data/spec/cucumber/core/test/location_spec.rb +5 -2
- data/spec/cucumber/core/test/result_spec.rb +31 -1
- data/spec/cucumber/core/test/runner_spec.rb +23 -21
- data/spec/cucumber/core/test/step_spec.rb +10 -9
- data/spec/cucumber/core_spec.rb +1 -1
- metadata +58 -40
- data/spec/capture_warnings.rb +0 -74
@@ -13,11 +13,12 @@ module Cucumber
|
|
13
13
|
include Core
|
14
14
|
include Core::Gherkin::Writer
|
15
15
|
|
16
|
+
let(:id) { double }
|
16
17
|
let(:name) { double }
|
17
18
|
let(:location) { double }
|
18
19
|
let(:tags) { double }
|
19
20
|
let(:language) { double }
|
20
|
-
let(:test_case) { Test::Case.new(name, test_steps, location, tags, language) }
|
21
|
+
let(:test_case) { Test::Case.new(id, name, test_steps, location, tags, language) }
|
21
22
|
let(:test_steps) { [double, double] }
|
22
23
|
|
23
24
|
context 'describing itself' do
|
@@ -45,7 +46,7 @@ module Cucumber
|
|
45
46
|
expect( first_hook ).to receive(:describe_to).ordered.and_yield
|
46
47
|
expect( second_hook ).to receive(:describe_to).ordered.and_yield
|
47
48
|
around_hooks = [first_hook, second_hook]
|
48
|
-
Test::Case.new(name, [], location, tags, language, around_hooks).describe_to(visitor, double)
|
49
|
+
Test::Case.new(id, name, [], location, tags, language, around_hooks).describe_to(visitor, double)
|
49
50
|
end
|
50
51
|
|
51
52
|
end
|
@@ -6,31 +6,29 @@ module Cucumber
|
|
6
6
|
module Core
|
7
7
|
module Test
|
8
8
|
describe DataTable do
|
9
|
-
let(:location) { Test::Location.new('foo.feature', 9..12) }
|
10
|
-
|
11
9
|
before do
|
12
10
|
@table = DataTable.new([
|
13
11
|
%w{one four seven},
|
14
12
|
%w{4444 55555 666666}
|
15
|
-
]
|
13
|
+
])
|
16
14
|
end
|
17
15
|
|
18
16
|
describe "equality" do
|
19
17
|
it "is equal to another table with the same data" do
|
20
|
-
expect( DataTable.new([[1,2],[3,4]]
|
18
|
+
expect( DataTable.new([[1,2],[3,4]]) ).to eq DataTable.new([[1,2],[3,4]])
|
21
19
|
end
|
22
20
|
|
23
21
|
it "is not equal to another table with different data" do
|
24
|
-
expect( DataTable.new([[1,2],[3,4]]
|
22
|
+
expect( DataTable.new([[1,2],[3,4]]) ).not_to eq DataTable.new([[1,2]])
|
25
23
|
end
|
26
24
|
|
27
25
|
it "is not equal to a non table" do
|
28
|
-
expect( DataTable.new([[1,2],[3,4]]
|
26
|
+
expect( DataTable.new([[1,2],[3,4]]) ).not_to eq Object.new
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
describe "#data_table?" do
|
33
|
-
let(:table) { DataTable.new([[1,2],[3,4]]
|
31
|
+
let(:table) { DataTable.new([[1,2],[3,4]]) }
|
34
32
|
|
35
33
|
it "returns true" do
|
36
34
|
expect(table).to be_data_table
|
@@ -38,7 +36,7 @@ module Cucumber
|
|
38
36
|
end
|
39
37
|
|
40
38
|
describe "#doc_string" do
|
41
|
-
let(:table) { DataTable.new([[1,2],[3,4]]
|
39
|
+
let(:table) { DataTable.new([[1,2],[3,4]]) }
|
42
40
|
|
43
41
|
it "returns false" do
|
44
42
|
expect(table).not_to be_doc_string
|
@@ -46,7 +44,7 @@ module Cucumber
|
|
46
44
|
end
|
47
45
|
|
48
46
|
describe "#map" do
|
49
|
-
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ]
|
47
|
+
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ]) }
|
50
48
|
|
51
49
|
it 'yields the contents of each cell to the block' do
|
52
50
|
|
@@ -54,7 +52,7 @@ module Cucumber
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'returns a new table with the cells modified by the block' do
|
57
|
-
expect( table.map { |cell| "*#{cell}*" } ).to eq DataTable.new([%w{*foo* *bar*}, %w{*1* *2*}]
|
55
|
+
expect( table.map { |cell| "*#{cell}*" } ).to eq DataTable.new([%w{*foo* *bar*}, %w{*1* *2*}])
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -63,14 +61,14 @@ module Cucumber
|
|
63
61
|
@table = DataTable.new([
|
64
62
|
%w{one 1111},
|
65
63
|
%w{two 22222}
|
66
|
-
]
|
64
|
+
])
|
67
65
|
end
|
68
66
|
|
69
67
|
it "should transpose the table" do
|
70
68
|
transposed = DataTable.new([
|
71
69
|
%w{one two},
|
72
70
|
%w{1111 22222}
|
73
|
-
]
|
71
|
+
])
|
74
72
|
expect( @table.transpose ).to eq( transposed )
|
75
73
|
end
|
76
74
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/test/location'
|
3
2
|
require 'cucumber/core/test/doc_string'
|
4
3
|
require 'unindent'
|
5
4
|
|
@@ -7,11 +6,10 @@ module Cucumber
|
|
7
6
|
module Core
|
8
7
|
module Test
|
9
8
|
describe DocString do
|
10
|
-
let(:
|
11
|
-
let(:doc_string) { DocString.new(content, content_type, location) }
|
9
|
+
let(:doc_string) { DocString.new(content, content_type) }
|
12
10
|
|
13
11
|
describe "#data_table?" do
|
14
|
-
let(:doc_string) { DocString.new("test", "text/plain"
|
12
|
+
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
15
13
|
|
16
14
|
it "returns false" do
|
17
15
|
expect(doc_string).not_to be_data_table
|
@@ -19,7 +17,7 @@ module Cucumber
|
|
19
17
|
end
|
20
18
|
|
21
19
|
describe "#doc_string" do
|
22
|
-
let(:doc_string) { DocString.new("test", "text/plain"
|
20
|
+
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
23
21
|
|
24
22
|
it "returns true" do
|
25
23
|
expect(doc_string).to be_doc_string
|
@@ -48,15 +46,15 @@ module Cucumber
|
|
48
46
|
let(:content_type) { 'text/plain' }
|
49
47
|
|
50
48
|
it 'is equal to another DocString with the same content and content_type' do
|
51
|
-
expect( doc_string ).to eq DocString.new(content, content_type
|
49
|
+
expect( doc_string ).to eq DocString.new(content, content_type)
|
52
50
|
end
|
53
51
|
|
54
52
|
it 'is not equal to another DocString with different content' do
|
55
|
-
expect( doc_string ).not_to eq DocString.new('bar', content_type
|
53
|
+
expect( doc_string ).not_to eq DocString.new('bar', content_type)
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'is not equal to another DocString with different content_type' do
|
59
|
-
expect( doc_string ).not_to eq DocString.new(content, 'text/html'
|
57
|
+
expect( doc_string ).not_to eq DocString.new(content, 'text/html')
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'is equal to a string with the same content' do
|
@@ -96,13 +94,12 @@ module Cucumber
|
|
96
94
|
end
|
97
95
|
|
98
96
|
context "inspect" do
|
99
|
-
let(:location) { Test::Location.new("features/feature.feature", 8) }
|
100
97
|
let(:content_type) { 'text/plain' }
|
101
98
|
|
102
99
|
it "provides a useful inspect method" do
|
103
|
-
doc_string = DocString.new("some text", content_type
|
100
|
+
doc_string = DocString.new("some text", content_type)
|
104
101
|
expect(doc_string.inspect).to eq <<-END.chomp.unindent
|
105
|
-
#<Cucumber::Core::Test::DocString
|
102
|
+
#<Cucumber::Core::Test::DocString
|
106
103
|
"""text/plain
|
107
104
|
some text
|
108
105
|
""">
|
@@ -100,14 +100,17 @@ module Cucumber::Core::Test
|
|
100
100
|
|
101
101
|
context "when the location is neither below pwd nor in an installed gem" do
|
102
102
|
it "use the absolute path to the file" do
|
103
|
-
|
103
|
+
# Use File.expand on expectation to ensure tests work on multiple platform.
|
104
|
+
# On Windows, it will return "C:/path/file.rb" as an absolute path while it will return "/path/file.rb" on Linux.
|
105
|
+
expect( Location.from_source_location("/path/file.rb", 1).file ).to eq File.expand_path("/path/file.rb")
|
104
106
|
end
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
110
|
describe "created from file-colon-line" do
|
109
111
|
it "handles also Windows paths" do
|
110
|
-
|
112
|
+
# Note: running this test on Windows will produce "c:/path/file.rb", but "c:\path\file.rb" on Linux.
|
113
|
+
expect( Location.from_file_colon_line("c:\\path\\file.rb:123").file ).to match(/c:(\\|\/)path(\\|\/)file.rb/)
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
@@ -23,6 +23,11 @@ module Cucumber::Core::Test
|
|
23
23
|
expect( result.to_s ).to eq "✓"
|
24
24
|
end
|
25
25
|
|
26
|
+
it "converts to a Cucumber::Message::TestResult" do
|
27
|
+
message = result.to_message
|
28
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::PASSED)
|
29
|
+
end
|
30
|
+
|
26
31
|
it "has a duration" do
|
27
32
|
expect( result.duration ).to eq duration
|
28
33
|
end
|
@@ -68,6 +73,11 @@ module Cucumber::Core::Test
|
|
68
73
|
expect( result.duration ).to eq duration
|
69
74
|
end
|
70
75
|
|
76
|
+
it "converts to a Cucumber::Message::TestResult" do
|
77
|
+
message = result.to_message
|
78
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::FAILED)
|
79
|
+
end
|
80
|
+
|
71
81
|
it "requires both constructor arguments" do
|
72
82
|
expect { Result::Failed.new }.to raise_error(ArgumentError)
|
73
83
|
expect { Result::Failed.new(duration) }.to raise_error(ArgumentError)
|
@@ -131,6 +141,11 @@ module Cucumber::Core::Test
|
|
131
141
|
specify { expect( result ).to be_unknown }
|
132
142
|
specify { expect( result ).not_to be_skipped }
|
133
143
|
specify { expect( result ).not_to be_flaky }
|
144
|
+
|
145
|
+
it "converts to a Cucumber::Message::TestResult" do
|
146
|
+
message = result.to_message
|
147
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::UNKNOWN)
|
148
|
+
end
|
134
149
|
end
|
135
150
|
|
136
151
|
describe Result::Raisable do
|
@@ -190,6 +205,11 @@ module Cucumber::Core::Test
|
|
190
205
|
result.describe_to(visitor, args)
|
191
206
|
end
|
192
207
|
|
208
|
+
it "converts to a Cucumber::Message::TestResult" do
|
209
|
+
message = result.to_message
|
210
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::UNDEFINED)
|
211
|
+
end
|
212
|
+
|
193
213
|
specify { expect( result.to_sym ).to eq :undefined }
|
194
214
|
|
195
215
|
specify { expect( result ).not_to be_passed }
|
@@ -214,6 +234,11 @@ module Cucumber::Core::Test
|
|
214
234
|
result.describe_to(visitor, args)
|
215
235
|
end
|
216
236
|
|
237
|
+
it "converts to a Cucumber::Message::TestResult" do
|
238
|
+
message = result.to_message
|
239
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::SKIPPED)
|
240
|
+
end
|
241
|
+
|
217
242
|
specify { expect( result.to_sym ).to eq :skipped }
|
218
243
|
|
219
244
|
specify { expect( result ).not_to be_passed }
|
@@ -236,6 +261,11 @@ module Cucumber::Core::Test
|
|
236
261
|
result.describe_to(visitor, args)
|
237
262
|
end
|
238
263
|
|
264
|
+
it "converts to a Cucumber::Message::TestResult" do
|
265
|
+
message = result.to_message
|
266
|
+
expect(message.status).to eq(Cucumber::Messages::TestStepFinished::TestStepResult::Status::PENDING)
|
267
|
+
end
|
268
|
+
|
239
269
|
specify { expect( result.to_sym ).to eq :pending }
|
240
270
|
|
241
271
|
specify { expect( result ).not_to be_passed }
|
@@ -259,7 +289,7 @@ module Cucumber::Core::Test
|
|
259
289
|
|
260
290
|
describe Result::StrictConfiguration do
|
261
291
|
subject(:strict_configuration) { Result::StrictConfiguration.new}
|
262
|
-
|
292
|
+
|
263
293
|
describe '#set_strict' do
|
264
294
|
context 'no type argument' do
|
265
295
|
it 'sets all result types to the setting argument' do
|
@@ -7,19 +7,21 @@ require 'cucumber/core/test/duration_matcher'
|
|
7
7
|
module Cucumber::Core::Test
|
8
8
|
describe Runner do
|
9
9
|
|
10
|
+
let(:step_id) { double }
|
11
|
+
let(:test_id) { double }
|
10
12
|
let(:name) { double }
|
11
13
|
let(:location) { double }
|
12
14
|
let(:tags) { double }
|
13
15
|
let(:language) { double }
|
14
|
-
let(:test_case) { Case.new(name, test_steps, location, tags, language) }
|
16
|
+
let(:test_case) { Case.new(test_id, name, test_steps, location, tags, language) }
|
15
17
|
let(:text) { double }
|
16
18
|
let(:runner) { Runner.new(event_bus) }
|
17
19
|
let(:event_bus) { double.as_null_object }
|
18
|
-
let(:passing) { Step.new(text, location, location).with_action {} }
|
19
|
-
let(:failing) { Step.new(text, location, location).with_action { raise exception } }
|
20
|
-
let(:pending) { Step.new(text, location, location).with_action { raise Result::Pending.new("TODO") } }
|
21
|
-
let(:skipping) { Step.new(text, location, location).with_action { raise Result::Skipped.new } }
|
22
|
-
let(:undefined) { Step.new(text, location, location) }
|
20
|
+
let(:passing) { Step.new(step_id, text, location, location).with_action {} }
|
21
|
+
let(:failing) { Step.new(step_id, text, location, location).with_action { raise exception } }
|
22
|
+
let(:pending) { Step.new(step_id, text, location, location).with_action { raise Result::Pending.new("TODO") } }
|
23
|
+
let(:skipping) { Step.new(step_id, text, location, location).with_action { raise Result::Skipped.new } }
|
24
|
+
let(:undefined) { Step.new(step_id, text, location, location) }
|
23
25
|
let(:exception) { StandardError.new('test error') }
|
24
26
|
|
25
27
|
before do
|
@@ -223,8 +225,8 @@ module Cucumber::Core::Test
|
|
223
225
|
|
224
226
|
context 'with multiple test cases' do
|
225
227
|
context 'when the first test case fails' do
|
226
|
-
let(:first_test_case) { Case.new(name, [failing], location, tags, language) }
|
227
|
-
let(:last_test_case) { Case.new(name, [passing], location, tags, language) }
|
228
|
+
let(:first_test_case) { Case.new(test_id, name, [failing], location, tags, language) }
|
229
|
+
let(:last_test_case) { Case.new(test_id, name, [passing], location, tags, language) }
|
228
230
|
let(:test_cases) { [first_test_case, last_test_case] }
|
229
231
|
|
230
232
|
it 'reports the results correctly for the following test case' do
|
@@ -244,9 +246,9 @@ module Cucumber::Core::Test
|
|
244
246
|
hook_mapping = UnskippableAction.new do |last_result|
|
245
247
|
result_spy = last_result
|
246
248
|
end
|
247
|
-
after_hook = HookStep.new(text, location, hook_mapping)
|
248
|
-
failing_step = Step.new(text, location).with_action { fail }
|
249
|
-
test_case = Case.new(name, [failing_step, after_hook], location, tags, language)
|
249
|
+
after_hook = HookStep.new(step_id, text, location, hook_mapping)
|
250
|
+
failing_step = Step.new(step_id, text, location).with_action { fail }
|
251
|
+
test_case = Case.new(test_id, name, [failing_step, after_hook], location, tags, language)
|
250
252
|
test_case.describe_to runner
|
251
253
|
expect(result_spy).to be_failed
|
252
254
|
end
|
@@ -256,8 +258,8 @@ module Cucumber::Core::Test
|
|
256
258
|
context "with around hooks" do
|
257
259
|
it "passes normally when around hooks don't fail" do
|
258
260
|
around_hook = AroundHook.new { |block| block.call }
|
259
|
-
passing_step = Step.new(text, location, location).with_action {}
|
260
|
-
test_case = Case.new(name, [passing_step], location, tags, language, [around_hook])
|
261
|
+
passing_step = Step.new(step_id, text, location, location).with_action {}
|
262
|
+
test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
|
261
263
|
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
262
264
|
expect(result).to be_passed
|
263
265
|
end
|
@@ -266,8 +268,8 @@ module Cucumber::Core::Test
|
|
266
268
|
|
267
269
|
it "gets a failed result if the Around hook fails before the test case is run" do
|
268
270
|
around_hook = AroundHook.new { |block| raise exception }
|
269
|
-
passing_step = Step.new(text, location, location).with_action {}
|
270
|
-
test_case = Case.new(name, [passing_step], location, tags, language, [around_hook])
|
271
|
+
passing_step = Step.new(step_id, text, location, location).with_action {}
|
272
|
+
test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
|
271
273
|
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
272
274
|
expect(result).to be_failed
|
273
275
|
expect(result.exception).to eq exception
|
@@ -277,8 +279,8 @@ module Cucumber::Core::Test
|
|
277
279
|
|
278
280
|
it "gets a failed result if the Around hook fails after the test case is run" do
|
279
281
|
around_hook = AroundHook.new { |block| block.call; raise exception }
|
280
|
-
passing_step = Step.new(text, location, location).with_action {}
|
281
|
-
test_case = Case.new(name, [passing_step], location, tags, language, [around_hook])
|
282
|
+
passing_step = Step.new(step_id, text, location, location).with_action {}
|
283
|
+
test_case = Case.new(test_id, name, [passing_step], location, tags, language, [around_hook])
|
282
284
|
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
283
285
|
expect(result).to be_failed
|
284
286
|
expect(result.exception).to eq exception
|
@@ -288,8 +290,8 @@ module Cucumber::Core::Test
|
|
288
290
|
|
289
291
|
it "fails when a step fails if the around hook works" do
|
290
292
|
around_hook = AroundHook.new { |block| block.call }
|
291
|
-
failing_step = Step.new(text, location, location).with_action { raise exception }
|
292
|
-
test_case = Case.new(name, [failing_step], location, tags, language, [around_hook])
|
293
|
+
failing_step = Step.new(step_id, text, location, location).with_action { raise exception }
|
294
|
+
test_case = Case.new(test_id, name, [failing_step], location, tags, language, [around_hook])
|
293
295
|
expect(event_bus).to receive(:test_case_finished).with(test_case, anything) do |reported_test_case, result|
|
294
296
|
expect(result).to be_failed
|
295
297
|
expect(result.exception).to eq exception
|
@@ -299,8 +301,8 @@ module Cucumber::Core::Test
|
|
299
301
|
|
300
302
|
it "sends after_test_step for a step interrupted by (a timeout in) the around hook" do
|
301
303
|
around_hook = AroundHook.new { |block| block.call; raise exception }
|
302
|
-
passing_step = Step.new(text, location, location).with_action {}
|
303
|
-
test_case = Case.new(name, [], location, tags, language, [around_hook])
|
304
|
+
passing_step = Step.new(step_id, text, location, location).with_action {}
|
305
|
+
test_case = Case.new(test_id, name, [], location, tags, language, [around_hook])
|
304
306
|
allow(runner).to receive(:running_test_step).and_return(passing_step)
|
305
307
|
expect(event_bus).to receive(:test_step_finished).with(passing_step, anything) do |reported_test_case, result|
|
306
308
|
expect(result).to be_failed
|
@@ -3,6 +3,7 @@ require 'cucumber/core/test/step'
|
|
3
3
|
|
4
4
|
module Cucumber::Core::Test
|
5
5
|
describe Step do
|
6
|
+
let(:id) { 'some-random-uid' }
|
6
7
|
let(:text) { 'step text' }
|
7
8
|
let(:location) { double }
|
8
9
|
|
@@ -10,7 +11,7 @@ module Cucumber::Core::Test
|
|
10
11
|
it "describes itself to a visitor" do
|
11
12
|
visitor = double
|
12
13
|
args = double
|
13
|
-
test_step = Step.new(text, location)
|
14
|
+
test_step = Step.new(id, text, location)
|
14
15
|
expect( visitor ).to receive(:test_step).with(test_step, args)
|
15
16
|
test_step.describe_to(visitor, args)
|
16
17
|
end
|
@@ -19,7 +20,7 @@ module Cucumber::Core::Test
|
|
19
20
|
describe "backtrace line" do
|
20
21
|
let(:text) { 'this step passes' }
|
21
22
|
let(:location) { Location.new('path/file.feature', 10) }
|
22
|
-
let(:test_step) { Step.new(text, location) }
|
23
|
+
let(:test_step) { Step.new(id, text, location) }
|
23
24
|
|
24
25
|
it "knows how to form the backtrace line" do
|
25
26
|
expect( test_step.backtrace_line ).to eq("path/file.feature:10:in `this step passes'")
|
@@ -30,7 +31,7 @@ module Cucumber::Core::Test
|
|
30
31
|
it "passes arbitrary arguments to the action's block" do
|
31
32
|
args_spy = nil
|
32
33
|
expected_args = [double, double]
|
33
|
-
test_step = Step.new(text, location).with_action do |*actual_args|
|
34
|
+
test_step = Step.new(id, text, location).with_action do |*actual_args|
|
34
35
|
args_spy = actual_args
|
35
36
|
end
|
36
37
|
test_step.execute(*expected_args)
|
@@ -39,7 +40,7 @@ module Cucumber::Core::Test
|
|
39
40
|
|
40
41
|
context "when a passing action exists" do
|
41
42
|
it "returns a passing result" do
|
42
|
-
test_step = Step.new(text, location).with_action {}
|
43
|
+
test_step = Step.new(id, text, location).with_action {}
|
43
44
|
expect( test_step.execute ).to be_passed
|
44
45
|
end
|
45
46
|
end
|
@@ -48,7 +49,7 @@ module Cucumber::Core::Test
|
|
48
49
|
let(:exception) { StandardError.new('oops') }
|
49
50
|
|
50
51
|
it "returns a failing result" do
|
51
|
-
test_step = Step.new(text, location).with_action { raise exception }
|
52
|
+
test_step = Step.new(id, text, location).with_action { raise exception }
|
52
53
|
result = test_step.execute
|
53
54
|
expect( result ).to be_failed
|
54
55
|
expect( result.exception ).to eq exception
|
@@ -57,7 +58,7 @@ module Cucumber::Core::Test
|
|
57
58
|
|
58
59
|
context "with no action" do
|
59
60
|
it "returns an Undefined result" do
|
60
|
-
test_step = Step.new(text, location)
|
61
|
+
test_step = Step.new(id, text, location)
|
61
62
|
result = test_step.execute
|
62
63
|
expect( result ).to be_undefined
|
63
64
|
end
|
@@ -65,7 +66,7 @@ module Cucumber::Core::Test
|
|
65
66
|
end
|
66
67
|
|
67
68
|
it "exposes the text and location of as attributes" do
|
68
|
-
test_step = Step.new(text, location)
|
69
|
+
test_step = Step.new(id, text, location)
|
69
70
|
expect( test_step.text ).to eq text
|
70
71
|
expect( test_step.location ).to eq location
|
71
72
|
end
|
@@ -73,13 +74,13 @@ module Cucumber::Core::Test
|
|
73
74
|
it "exposes the location of the action as attribute" do
|
74
75
|
location = double
|
75
76
|
action = double(location: location)
|
76
|
-
test_step = Step.new(text, location, action)
|
77
|
+
test_step = Step.new(id, text, location, action)
|
77
78
|
expect( test_step.action_location ).to eq location
|
78
79
|
end
|
79
80
|
|
80
81
|
it "returns the text when converted to a string" do
|
81
82
|
text = 'a passing step'
|
82
|
-
test_step = Step.new(text, location)
|
83
|
+
test_step = Step.new(id, text, location)
|
83
84
|
expect( test_step.to_s ).to eq 'a passing step'
|
84
85
|
end
|
85
86
|
|