cucumber-core 11.0.0 → 11.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +204 -291
- data/README.md +0 -1
- data/lib/cucumber/core/test/case.rb +11 -1
- data/lib/cucumber/core/test/data_table.rb +4 -0
- data/lib/cucumber/core/test/doc_string.rb +4 -1
- data/lib/cucumber/core/test/empty_multiline_argument.rb +2 -2
- data/lib/cucumber/core/test/filters/locations_filter.rb +1 -1
- data/lib/cucumber/core/test/location.rb +7 -0
- data/lib/cucumber/core/test/step.rb +4 -0
- metadata +21 -86
- data/lib/cucumber/core/version.rb +0 -10
- data/spec/coverage.rb +0 -12
- data/spec/cucumber/core/compiler_spec.rb +0 -241
- data/spec/cucumber/core/event_bus_spec.rb +0 -163
- data/spec/cucumber/core/event_spec.rb +0 -40
- data/spec/cucumber/core/filter_spec.rb +0 -101
- data/spec/cucumber/core/gherkin/parser_spec.rb +0 -162
- data/spec/cucumber/core/gherkin/writer_spec.rb +0 -332
- data/spec/cucumber/core/report/summary_spec.rb +0 -178
- data/spec/cucumber/core/test/action_spec.rb +0 -153
- data/spec/cucumber/core/test/case_spec.rb +0 -125
- data/spec/cucumber/core/test/data_table_spec.rb +0 -79
- data/spec/cucumber/core/test/doc_string_spec.rb +0 -111
- data/spec/cucumber/core/test/duration_matcher.rb +0 -20
- data/spec/cucumber/core/test/empty_multiline_argument_spec.rb +0 -28
- data/spec/cucumber/core/test/filters/locations_filter_spec.rb +0 -271
- data/spec/cucumber/core/test/location_spec.rb +0 -129
- data/spec/cucumber/core/test/result_spec.rb +0 -504
- data/spec/cucumber/core/test/runner_spec.rb +0 -320
- data/spec/cucumber/core/test/step_spec.rb +0 -88
- data/spec/cucumber/core/test/timer_spec.rb +0 -25
- data/spec/cucumber/core_spec.rb +0 -262
- data/spec/report_api_spy.rb +0 -25
@@ -1,178 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'cucumber/core/event_bus'
|
3
|
-
require 'cucumber/core/events'
|
4
|
-
require 'cucumber/core/report/summary'
|
5
|
-
require 'cucumber/core/test/result'
|
6
|
-
|
7
|
-
module Cucumber::Core::Report
|
8
|
-
describe Summary do
|
9
|
-
let(:event_bus) { ::Cucumber::Core::EventBus.new(registry) }
|
10
|
-
let(:registry) { ::Cucumber::Core::Events.registry }
|
11
|
-
let(:passed_result) { ::Cucumber::Core::Test::Result::Passed.new(duration) }
|
12
|
-
let(:failed_result) { ::Cucumber::Core::Test::Result::Failed.new(duration, exception) }
|
13
|
-
let(:pending_result) { ::Cucumber::Core::Test::Result::Pending.new(duration) }
|
14
|
-
let(:skipped_result) { ::Cucumber::Core::Test::Result::Skipped.new(duration) }
|
15
|
-
let(:undefined_result) { ::Cucumber::Core::Test::Result::Undefined.new(duration) }
|
16
|
-
let(:duration) { double }
|
17
|
-
let(:exception) { double }
|
18
|
-
|
19
|
-
before(:each) { @summary = Summary.new(event_bus) }
|
20
|
-
|
21
|
-
context "test case summary" do
|
22
|
-
let(:test_case) { double }
|
23
|
-
|
24
|
-
it "counts passed test cases" do
|
25
|
-
event_bus.send(:test_case_finished, test_case, passed_result)
|
26
|
-
|
27
|
-
expect( @summary.test_cases.total(:passed) ).to eq(1)
|
28
|
-
expect( @summary.test_cases.total ).to eq(1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "counts failed test cases" do
|
32
|
-
event_bus.send(:test_case_finished, test_case, failed_result)
|
33
|
-
|
34
|
-
expect( @summary.test_cases.total(:failed) ).to eq(1)
|
35
|
-
expect( @summary.test_cases.total ).to eq(1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "counts pending test cases" do
|
39
|
-
event_bus.send(:test_case_finished, test_case, pending_result)
|
40
|
-
|
41
|
-
expect( @summary.test_cases.total(:pending) ).to eq(1)
|
42
|
-
expect( @summary.test_cases.total ).to eq(1)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "counts skipped test cases" do
|
46
|
-
event_bus.send(:test_case_finished, test_case, skipped_result)
|
47
|
-
|
48
|
-
expect( @summary.test_cases.total(:skipped) ).to eq(1)
|
49
|
-
expect( @summary.test_cases.total ).to eq(1)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "counts undefined test cases" do
|
53
|
-
event_bus.send(:test_case_finished, test_case, undefined_result)
|
54
|
-
|
55
|
-
expect( @summary.test_cases.total(:undefined) ).to eq(1)
|
56
|
-
expect( @summary.test_cases.total ).to eq(1)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "handles flaky test cases" do
|
60
|
-
allow(test_case).to receive(:==).and_return(false, true)
|
61
|
-
event_bus.send(:test_case_finished, test_case, failed_result)
|
62
|
-
event_bus.send(:test_case_finished, test_case, passed_result)
|
63
|
-
|
64
|
-
expect( @summary.test_cases.total(:failed) ).to eq(0)
|
65
|
-
expect( @summary.test_cases.total(:flaky) ).to eq(1)
|
66
|
-
expect( @summary.test_cases.total ).to eq(1)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "handless flaky with following skip test cases" do
|
70
|
-
allow(test_case).to receive(:==).and_return(false, true)
|
71
|
-
event_bus.send(:test_case_finished, test_case, failed_result)
|
72
|
-
event_bus.send(:test_case_finished, test_case, skipped_result)
|
73
|
-
|
74
|
-
expect( @summary.test_cases.total(:failed) ).to eq(0)
|
75
|
-
expect( @summary.test_cases.total(:skipped) ).to eq(0)
|
76
|
-
expect( @summary.test_cases.total(:flaky) ).to eq(1)
|
77
|
-
expect( @summary.test_cases.total ).to eq(1)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "test step summary" do
|
82
|
-
context "with test steps from gherkin steps" do
|
83
|
-
let(:test_step) { double }
|
84
|
-
|
85
|
-
before(:each) do
|
86
|
-
expect( test_step ).to receive(:hook?).and_return(false)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "counts passed test steps" do
|
90
|
-
event_bus.send(:test_step_finished, test_step, passed_result)
|
91
|
-
|
92
|
-
expect( @summary.test_steps.total(:passed) ).to eq(1)
|
93
|
-
expect( @summary.test_steps.total ).to eq(1)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "counts failed test cases" do
|
97
|
-
event_bus.send(:test_step_finished, test_step, failed_result)
|
98
|
-
|
99
|
-
expect( @summary.test_steps.total(:failed) ).to eq(1)
|
100
|
-
expect( @summary.test_steps.total ).to eq(1)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "counts pending test cases" do
|
104
|
-
event_bus.send(:test_step_finished, test_step, pending_result)
|
105
|
-
|
106
|
-
expect( @summary.test_steps.total(:pending) ).to eq(1)
|
107
|
-
expect( @summary.test_steps.total ).to eq(1)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "counts skipped test cases" do
|
111
|
-
event_bus.send(:test_step_finished, test_step, skipped_result)
|
112
|
-
|
113
|
-
expect( @summary.test_steps.total(:skipped) ).to eq(1)
|
114
|
-
expect( @summary.test_steps.total ).to eq(1)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "counts undefined test cases" do
|
118
|
-
event_bus.send(:test_step_finished, test_step, undefined_result)
|
119
|
-
|
120
|
-
expect( @summary.test_steps.total(:undefined) ).to eq(1)
|
121
|
-
expect( @summary.test_steps.total ).to eq(1)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "with test steps not from gherkin steps" do
|
126
|
-
let(:test_step) { double }
|
127
|
-
|
128
|
-
before(:each) do
|
129
|
-
expect( test_step ).to receive(:hook?).and_return(true)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "ignores test steps not defined by gherkin steps" do
|
133
|
-
event_bus.send(:test_step_finished, test_step, passed_result)
|
134
|
-
|
135
|
-
expect( @summary.test_steps.total ).to eq(0)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
context "ok? result" do
|
141
|
-
let(:test_case) { double }
|
142
|
-
|
143
|
-
it "passed test case is ok" do
|
144
|
-
event_bus.send(:test_case_finished, test_case, passed_result)
|
145
|
-
|
146
|
-
expect( @summary.ok? ).to eq true
|
147
|
-
end
|
148
|
-
|
149
|
-
it "skipped test case is ok" do
|
150
|
-
event_bus.send(:test_case_finished, test_case, skipped_result)
|
151
|
-
|
152
|
-
expect( @summary.ok? ).to eq true
|
153
|
-
end
|
154
|
-
|
155
|
-
it "failed test case is not ok" do
|
156
|
-
event_bus.send(:test_case_finished, test_case, failed_result)
|
157
|
-
|
158
|
-
expect( @summary.ok? ).to eq false
|
159
|
-
end
|
160
|
-
|
161
|
-
it "pending test case is ok if not strict" do
|
162
|
-
event_bus.send(:test_case_finished, test_case, pending_result)
|
163
|
-
|
164
|
-
expect( @summary.ok? ).to eq true
|
165
|
-
be_strict = ::Cucumber::Core::Test::Result::StrictConfiguration.new([:pending])
|
166
|
-
expect( @summary.ok?(be_strict) ).to eq false
|
167
|
-
end
|
168
|
-
|
169
|
-
it "undefined test case is ok if not strict" do
|
170
|
-
event_bus.send(:test_case_finished, test_case, undefined_result)
|
171
|
-
|
172
|
-
expect( @summary.ok? ).to eq true
|
173
|
-
be_strict = ::Cucumber::Core::Test::Result::StrictConfiguration.new([:undefined])
|
174
|
-
expect( @summary.ok?(be_strict) ).to eq false
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
@@ -1,153 +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 Test::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
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core'
|
3
|
-
require 'cucumber/core/gherkin/writer'
|
4
|
-
require 'cucumber/core/platform'
|
5
|
-
require 'cucumber/core/test/case'
|
6
|
-
require 'unindent'
|
7
|
-
|
8
|
-
module Cucumber
|
9
|
-
module Core
|
10
|
-
module Test
|
11
|
-
describe Case do
|
12
|
-
include Core
|
13
|
-
include Core::Gherkin::Writer
|
14
|
-
|
15
|
-
let(:id) { double }
|
16
|
-
let(:name) { double }
|
17
|
-
let(:location) { double }
|
18
|
-
let(:tags) { double }
|
19
|
-
let(:language) { double }
|
20
|
-
let(:test_case) { Test::Case.new(id, name, test_steps, location, tags, language) }
|
21
|
-
let(:test_steps) { [double, double] }
|
22
|
-
|
23
|
-
context 'describing itself' do
|
24
|
-
it "describes itself to a visitor" do
|
25
|
-
visitor = double
|
26
|
-
args = double
|
27
|
-
expect(visitor).to receive(:test_case).with(test_case, args)
|
28
|
-
test_case.describe_to(visitor, args)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "asks each test_step to describe themselves to the visitor" do
|
32
|
-
visitor = double
|
33
|
-
args = double
|
34
|
-
test_steps.each do |test_step|
|
35
|
-
expect(test_step).to receive(:describe_to).with(visitor, args)
|
36
|
-
end
|
37
|
-
allow(visitor).to receive(:test_case).and_yield(visitor)
|
38
|
-
test_case.describe_to(visitor, args)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "describes around hooks in order" do
|
42
|
-
visitor = double
|
43
|
-
allow(visitor).to receive(:test_case).and_yield(visitor)
|
44
|
-
first_hook = double
|
45
|
-
second_hook = double
|
46
|
-
expect(first_hook).to receive(:describe_to).ordered.and_yield
|
47
|
-
expect(second_hook).to receive(:describe_to).ordered.and_yield
|
48
|
-
around_hooks = [first_hook, second_hook]
|
49
|
-
Test::Case.new(id, name, [], location, tags, language, around_hooks).describe_to(visitor, double)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#name" do
|
54
|
-
it "the name is passed when creating the test case" do
|
55
|
-
expect(test_case.name).to eq(name)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#location" do
|
60
|
-
it "the location is passed when creating the test case" do
|
61
|
-
expect(test_case.location).to eq(location)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#tags" do
|
66
|
-
it "the tags are passed when creating the test case" do
|
67
|
-
expect(test_case.tags).to eq(tags)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "matching tags" do
|
72
|
-
let(:tags) { ['@a', '@b', '@c'].map { |value| Tag.new(location, value) } }
|
73
|
-
it "matches tags using tag expressions" do
|
74
|
-
expect(test_case.match_tags?(['@a and @b'])).to be_truthy
|
75
|
-
expect(test_case.match_tags?(['@a or @d'])).to be_truthy
|
76
|
-
expect(test_case.match_tags?(['not @d'])).to be_truthy
|
77
|
-
expect(test_case.match_tags?(['@a and @d'])).to be_falsy
|
78
|
-
end
|
79
|
-
|
80
|
-
it "matches handles multiple expressions" do
|
81
|
-
expect(test_case.match_tags?(['@a and @b', 'not @d'])).to be_truthy
|
82
|
-
expect(test_case.match_tags?(['@a and @b', 'not @c'])).to be_falsy
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "matching names" do
|
87
|
-
let(:name) { 'scenario' }
|
88
|
-
it "matches names against regexp" do
|
89
|
-
expect(test_case.match_name?(/scenario/)).to be_truthy
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#language" do
|
94
|
-
let(:language) { 'en-pirate' }
|
95
|
-
it "the language is passed when creating the test case" do
|
96
|
-
expect(test_case.language).to eq 'en-pirate'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "equality" do
|
101
|
-
it "is equal to another test case at the same location" do
|
102
|
-
gherkin = gherkin('features/foo.feature') do
|
103
|
-
feature do
|
104
|
-
scenario do
|
105
|
-
step 'text'
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
test_case_instances = []
|
110
|
-
receiver = double.as_null_object
|
111
|
-
allow(receiver).to receive(:test_case) do |test_case|
|
112
|
-
test_case_instances << test_case
|
113
|
-
end
|
114
|
-
2.times { compile([gherkin], receiver) }
|
115
|
-
expect(test_case_instances.length).to eq 2
|
116
|
-
expect(test_case_instances.uniq.length).to eq 1
|
117
|
-
expect(test_case_instances[0]).to be_eql test_case_instances[1]
|
118
|
-
expect(test_case_instances[0]).to eq test_case_instances[1]
|
119
|
-
expect(test_case_instances[0]).not_to equal test_case_instances[1]
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'cucumber/core/test/data_table'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Core
|
7
|
-
module Test
|
8
|
-
describe DataTable do
|
9
|
-
before do
|
10
|
-
@table = DataTable.new([
|
11
|
-
%w{one four seven},
|
12
|
-
%w{4444 55555 666666}
|
13
|
-
])
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "equality" do
|
17
|
-
it "is equal to another table with the same data" do
|
18
|
-
expect( DataTable.new([[1, 2], [3, 4]]) ).to eq DataTable.new([[1, 2], [3, 4]])
|
19
|
-
end
|
20
|
-
|
21
|
-
it "is not equal to another table with different data" do
|
22
|
-
expect( DataTable.new([[1, 2], [3, 4]]) ).not_to eq DataTable.new([[1, 2]])
|
23
|
-
end
|
24
|
-
|
25
|
-
it "is not equal to a non table" do
|
26
|
-
expect( DataTable.new([[1, 2], [3, 4]]) ).not_to eq Object.new
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#data_table?" do
|
31
|
-
let(:table) { DataTable.new([[1, 2], [3, 4]]) }
|
32
|
-
|
33
|
-
it "returns true" do
|
34
|
-
expect(table).to be_data_table
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#doc_string" do
|
39
|
-
let(:table) { DataTable.new([[1, 2], [3, 4]]) }
|
40
|
-
|
41
|
-
it "returns false" do
|
42
|
-
expect(table).not_to be_doc_string
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#map" do
|
47
|
-
let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ]) }
|
48
|
-
|
49
|
-
it 'yields the contents of each cell to the block' do
|
50
|
-
|
51
|
-
expect { |b| table.map(&b) }.to yield_successive_args('foo', 'bar', '1', '2')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'returns a new table with the cells modified by the block' do
|
55
|
-
expect( table.map { |cell| "*#{cell}*" } ).to eq DataTable.new([%w{*foo* *bar*}, %w{*1* *2*}])
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#transpose" do
|
60
|
-
before(:each) do
|
61
|
-
@table = DataTable.new([
|
62
|
-
%w{one 1111},
|
63
|
-
%w{two 22222}
|
64
|
-
])
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should transpose the table" do
|
68
|
-
transposed = DataTable.new([
|
69
|
-
%w{one two},
|
70
|
-
%w{1111 22222}
|
71
|
-
])
|
72
|
-
expect( @table.transpose ).to eq( transposed )
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/test/doc_string'
|
3
|
-
require 'unindent'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Core
|
7
|
-
module Test
|
8
|
-
describe DocString do
|
9
|
-
let(:doc_string) { DocString.new(content, content_type) }
|
10
|
-
|
11
|
-
describe "#data_table?" do
|
12
|
-
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
13
|
-
|
14
|
-
it "returns false" do
|
15
|
-
expect(doc_string).not_to be_data_table
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#doc_string" do
|
20
|
-
let(:doc_string) { DocString.new("test", "text/plain" ) }
|
21
|
-
|
22
|
-
it "returns true" do
|
23
|
-
expect(doc_string).to be_doc_string
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context '#map' do
|
28
|
-
let(:content) { 'original content' }
|
29
|
-
let(:content_type) { double }
|
30
|
-
|
31
|
-
it 'yields with the content' do
|
32
|
-
expect { |b| doc_string.map(&b) }.to yield_with_args(content)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns a new docstring with new content' do
|
36
|
-
expect( doc_string.map { 'foo' }.content ).to eq 'foo'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'raises an error if no block is given' do
|
40
|
-
expect { doc_string.map }.to raise_error ArgumentError
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'equality' do
|
45
|
-
let(:content) { 'foo' }
|
46
|
-
let(:content_type) { 'text/plain' }
|
47
|
-
|
48
|
-
it 'is equal to another DocString with the same content and content_type' do
|
49
|
-
expect( doc_string ).to eq DocString.new(content, content_type)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'is not equal to another DocString with different content' do
|
53
|
-
expect( doc_string ).not_to eq DocString.new('bar', content_type)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'is not equal to another DocString with different content_type' do
|
57
|
-
expect( doc_string ).not_to eq DocString.new(content, 'text/html')
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'is equal to a string with the same content' do
|
61
|
-
expect( doc_string ).to eq 'foo'
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'returns false when compared with something odd' do
|
65
|
-
expect( doc_string ).not_to eq 5
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'quacking like a String' do
|
70
|
-
let(:content) { String.new('content') }
|
71
|
-
let(:content_type) { 'text/plain' }
|
72
|
-
|
73
|
-
it 'delegates #encoding to the content string' do
|
74
|
-
content.force_encoding('us-ascii')
|
75
|
-
expect( doc_string.encoding ).to eq Encoding.find('US-ASCII')
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'allows implicit conversion to a String' do
|
79
|
-
expect( 'expected content' ).to include(doc_string)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'allows explicit conversion to a String' do
|
83
|
-
expect( doc_string.to_s ).to eq 'content'
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'delegates #gsub to the content string' do
|
87
|
-
expect( doc_string.gsub(/n/, '_') ).to eq 'co_te_t'
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'delegates #split to the content string' do
|
91
|
-
expect(doc_string.split('n')).to eq ['co', 'te', 't']
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "inspect" do
|
97
|
-
let(:content_type) { 'text/plain' }
|
98
|
-
|
99
|
-
it "provides a useful inspect method" do
|
100
|
-
doc_string = DocString.new("some text", content_type)
|
101
|
-
expect(doc_string.inspect).to eq <<-END.chomp.unindent
|
102
|
-
#<Cucumber::Core::Test::DocString
|
103
|
-
"""text/plain
|
104
|
-
some text
|
105
|
-
""">
|
106
|
-
END
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require 'cucumber/core/test/result'
|
4
|
-
require 'rspec/expectations'
|
5
|
-
|
6
|
-
module Cucumber::Core::Test
|
7
|
-
RSpec::Matchers.define :be_duration do |expected|
|
8
|
-
match do |actual|
|
9
|
-
actual.tap { |duration| @nanoseconds = duration.nanoseconds }
|
10
|
-
@nanoseconds == expected
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
RSpec::Matchers.define :an_unknown_duration do
|
15
|
-
match do |actual|
|
16
|
-
actual.tap { raise "#tap block was executed, not an UnknownDuration" }
|
17
|
-
expect(actual).to respond_to(:nanoseconds)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/test/location'
|
3
|
-
require 'cucumber/core/test/empty_multiline_argument'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Core
|
7
|
-
module Test
|
8
|
-
describe EmptyMultilineArgument do
|
9
|
-
|
10
|
-
let(:location) { double }
|
11
|
-
let(:arg) { EmptyMultilineArgument.new }
|
12
|
-
|
13
|
-
describe "#data_table?" do
|
14
|
-
it "returns false" do
|
15
|
-
expect(arg).not_to be_data_table
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#doc_string" do
|
20
|
-
it "returns false" do
|
21
|
-
expect(arg).not_to be_doc_string
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|