cucumber-core 1.1.3 → 1.2.0
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/HISTORY.md +16 -2
- data/lib/cucumber/core/ast/background.rb +6 -7
- data/lib/cucumber/core/ast/comment.rb +1 -1
- data/lib/cucumber/core/ast/doc_string.rb +0 -1
- data/lib/cucumber/core/ast/examples_table.rb +12 -9
- data/lib/cucumber/core/ast/feature.rb +3 -4
- data/lib/cucumber/core/ast/names.rb +4 -8
- data/lib/cucumber/core/ast/outline_step.rb +4 -4
- data/lib/cucumber/core/ast/scenario.rb +4 -4
- data/lib/cucumber/core/ast/scenario_outline.rb +4 -5
- data/lib/cucumber/core/ast/step.rb +5 -5
- data/lib/cucumber/core/gherkin/ast_builder.rb +12 -2
- data/lib/cucumber/core/test/action.rb +9 -2
- data/lib/cucumber/core/test/result.rb +65 -13
- data/lib/cucumber/core/test/runner.rb +2 -0
- data/lib/cucumber/core/test/step.rb +7 -3
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/cucumber/core/ast/examples_table_spec.rb +26 -13
- data/spec/cucumber/core/ast/outline_step_spec.rb +13 -6
- data/spec/cucumber/core/ast/step_spec.rb +28 -15
- data/spec/cucumber/core/test/action_spec.rb +30 -1
- data/spec/cucumber/core/test/result_spec.rb +155 -25
- data/spec/cucumber/core/test/runner_spec.rb +54 -11
- data/spec/cucumber/core/test/step_spec.rb +17 -2
- metadata +4 -3
@@ -97,6 +97,8 @@ module Cucumber
|
|
97
97
|
|
98
98
|
def execute(test_step, monitor, &continue)
|
99
99
|
result = test_step.execute(monitor.result, &continue)
|
100
|
+
result = result.with_message(%(Undefined step: "#{test_step.name}")) if result.undefined?
|
101
|
+
result = result.with_appended_backtrace(test_step.source.last) if test_step.respond_to?(:source)
|
100
102
|
result.describe_to(monitor, result)
|
101
103
|
end
|
102
104
|
|
@@ -7,7 +7,7 @@ module Cucumber
|
|
7
7
|
class Step
|
8
8
|
attr_reader :source
|
9
9
|
|
10
|
-
def initialize(source, action = Test::UndefinedAction.new)
|
10
|
+
def initialize(source, action = Test::UndefinedAction.new(source.last.location))
|
11
11
|
raise ArgumentError if source.any?(&:nil?)
|
12
12
|
@source, @action = source, action
|
13
13
|
end
|
@@ -31,8 +31,8 @@ module Cucumber
|
|
31
31
|
@action.execute(*args)
|
32
32
|
end
|
33
33
|
|
34
|
-
def with_action(&block)
|
35
|
-
self.class.new(source, Test::Action.new(&block))
|
34
|
+
def with_action(location = nil, &block)
|
35
|
+
self.class.new(source, Test::Action.new(location, &block))
|
36
36
|
end
|
37
37
|
|
38
38
|
def name
|
@@ -43,6 +43,10 @@ module Cucumber
|
|
43
43
|
source.last.location
|
44
44
|
end
|
45
45
|
|
46
|
+
def action_location
|
47
|
+
@action.location
|
48
|
+
end
|
49
|
+
|
46
50
|
def match_locations?(queried_locations)
|
47
51
|
return true if queried_locations.include? location
|
48
52
|
source.any? { |s| s.match_locations?(queried_locations) }
|
@@ -4,9 +4,10 @@ module Cucumber::Core::Ast
|
|
4
4
|
describe ExamplesTable do
|
5
5
|
let(:location) { double(:to_s => 'file.feature:8') }
|
6
6
|
let(:language) { double }
|
7
|
+
let(:comments) { double }
|
7
8
|
|
8
9
|
describe ExamplesTable::Header do
|
9
|
-
let(:header) { ExamplesTable::Header.new(%w{foo bar baz}, location) }
|
10
|
+
let(:header) { ExamplesTable::Header.new(%w{foo bar baz}, location, comments) }
|
10
11
|
|
11
12
|
describe 'location' do
|
12
13
|
it 'knows the file and line number' do
|
@@ -14,9 +15,15 @@ module Cucumber::Core::Ast
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
describe 'comments' do
|
19
|
+
it "has comments" do
|
20
|
+
expect( header ).to respond_to(:comments)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
context 'building a row' do
|
18
25
|
it 'includes the header values as keys' do
|
19
|
-
expect( header.build_row(%w{1 2 3}, 1, location, language) ).to eq ExamplesTable::Row.new({'foo' => '1', 'bar' => '2', 'baz' => '3'}, 1, location, language)
|
26
|
+
expect( header.build_row(%w{1 2 3}, 1, location, language, comments) ).to eq ExamplesTable::Row.new({'foo' => '1', 'bar' => '2', 'baz' => '3'}, 1, location, language, comments)
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -24,21 +31,27 @@ module Cucumber::Core::Ast
|
|
24
31
|
|
25
32
|
describe 'location' do
|
26
33
|
it 'knows the file and line number' do
|
27
|
-
row = ExamplesTable::Row.new({}, 1, location, language)
|
34
|
+
row = ExamplesTable::Row.new({}, 1, location, language, comments)
|
28
35
|
expect( row.file_colon_line ).to eq 'file.feature:8'
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
39
|
describe 'language' do
|
33
40
|
it "has a language" do
|
34
|
-
expect( ExamplesTable::Row.new({}, 1, location, language) ).to respond_to(:language)
|
41
|
+
expect( ExamplesTable::Row.new({}, 1, location, language, comments) ).to respond_to(:language)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'comments' do
|
46
|
+
it "has comments" do
|
47
|
+
expect( ExamplesTable::Row.new({}, 1, location, language, comments) ).to respond_to(:comments)
|
35
48
|
end
|
36
49
|
end
|
37
50
|
|
38
51
|
describe "expanding a string" do
|
39
52
|
context "when an argument matches" do
|
40
53
|
it "replaces the argument with the value from the row" do
|
41
|
-
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language)
|
54
|
+
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
|
42
55
|
text = 'this <arg> a test'
|
43
56
|
expect( row.expand(text) ).to eq 'this replacement a test'
|
44
57
|
end
|
@@ -46,7 +59,7 @@ module Cucumber::Core::Ast
|
|
46
59
|
|
47
60
|
context "when the replacement value is nil" do
|
48
61
|
it "uses an empty string for the replacement" do
|
49
|
-
row = ExamplesTable::Row.new({'color' => nil}, 1, location, language)
|
62
|
+
row = ExamplesTable::Row.new({'color' => nil}, 1, location, language, comments)
|
50
63
|
text = 'a <color> cucumber'
|
51
64
|
expect( row.expand(text) ).to eq 'a cucumber'
|
52
65
|
end
|
@@ -54,7 +67,7 @@ module Cucumber::Core::Ast
|
|
54
67
|
|
55
68
|
context "when an argument does not match" do
|
56
69
|
it "ignores the arguments that do not match" do
|
57
|
-
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language)
|
70
|
+
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments)
|
58
71
|
text = 'foo <x> bar <z>'
|
59
72
|
expect( row.expand(text) ).to eq 'foo 1 bar <z>'
|
60
73
|
end
|
@@ -63,7 +76,7 @@ module Cucumber::Core::Ast
|
|
63
76
|
|
64
77
|
describe 'accesing the values' do
|
65
78
|
it 'returns the actual row values' do
|
66
|
-
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language)
|
79
|
+
row = ExamplesTable::Row.new({'x' => '1', 'y' => '2'}, 1, location, language, comments)
|
67
80
|
expect( row.values ).to eq ['1', '2']
|
68
81
|
end
|
69
82
|
end
|
@@ -72,16 +85,16 @@ module Cucumber::Core::Ast
|
|
72
85
|
let(:data) { {} }
|
73
86
|
let(:number) { double }
|
74
87
|
let(:location) { double }
|
75
|
-
let(:original) { ExamplesTable::Row.new(data, number, location, language) }
|
88
|
+
let(:original) { ExamplesTable::Row.new(data, number, location, language, comments) }
|
76
89
|
|
77
90
|
it 'is equal to another instance with the same data, number and location' do
|
78
|
-
expect( original ).to eq ExamplesTable::Row.new(data, number, location, language)
|
91
|
+
expect( original ).to eq ExamplesTable::Row.new(data, number, location, language, comments)
|
79
92
|
end
|
80
93
|
|
81
94
|
it 'is not equal to another instance with different data, number or location' do
|
82
|
-
expect( original ).not_to eq ExamplesTable::Row.new({'x' => 'y'}, number, location, language)
|
83
|
-
expect( original ).not_to eq ExamplesTable::Row.new(data, double, location, language)
|
84
|
-
expect( original ).not_to eq ExamplesTable::Row.new(data, number, double, double)
|
95
|
+
expect( original ).not_to eq ExamplesTable::Row.new({'x' => 'y'}, number, location, language, comments)
|
96
|
+
expect( original ).not_to eq ExamplesTable::Row.new(data, double, location, language, comments)
|
97
|
+
expect( original ).not_to eq ExamplesTable::Row.new(data, number, double, double, double)
|
85
98
|
end
|
86
99
|
|
87
100
|
it 'is not equal to another type of object' do
|
@@ -8,10 +8,11 @@ module Cucumber
|
|
8
8
|
module Core
|
9
9
|
module Ast
|
10
10
|
describe OutlineStep do
|
11
|
-
let(:outline_step) { OutlineStep.new(node, language, location, keyword, name, multiline_arg) }
|
11
|
+
let(:outline_step) { OutlineStep.new(node, language, location, comments, keyword, name, multiline_arg) }
|
12
12
|
let(:node) { double }
|
13
13
|
let(:language) { double }
|
14
14
|
let(:location) { double }
|
15
|
+
let(:comments) { double }
|
15
16
|
let(:keyword) { double }
|
16
17
|
let(:name) { 'anything' }
|
17
18
|
let(:multiline_arg) { EmptyMultilineArgument.new }
|
@@ -27,19 +28,25 @@ module Cucumber
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
describe 'comments' do
|
32
|
+
it "has comments" do
|
33
|
+
expect( outline_step ).to respond_to(:comments)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
describe "converting to a Step" do
|
31
38
|
context "a single argument in the name" do
|
32
39
|
let(:name) { 'a <color> cucumber' }
|
33
40
|
|
34
41
|
it "replaces the argument" do
|
35
|
-
row = ExamplesTable::Row.new({'color' => 'green'}, 1, location, language)
|
42
|
+
row = ExamplesTable::Row.new({'color' => 'green'}, 1, location, language, comments)
|
36
43
|
expect( outline_step.to_step(row).name ).to eq 'a green cucumber'
|
37
44
|
end
|
38
45
|
|
39
46
|
end
|
40
47
|
|
41
48
|
context "when the step has a DataTable" do
|
42
|
-
let(:outline_step) { OutlineStep.new(node, language, location, keyword, name, table) }
|
49
|
+
let(:outline_step) { OutlineStep.new(node, language, location, comments, keyword, name, table) }
|
43
50
|
let(:name) { "anything" }
|
44
51
|
let(:table) { DataTable.new([['x', 'y'],['a', 'a <arg>']], Location.new('foo.feature', 23)) }
|
45
52
|
|
@@ -49,7 +56,7 @@ module Cucumber
|
|
49
56
|
expect( visitor ).to receive(:data_table) do |data_table|
|
50
57
|
expect( data_table.raw ).to eq [['x', 'y'], ['a', 'a replacement']]
|
51
58
|
end
|
52
|
-
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language)
|
59
|
+
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
|
53
60
|
step = outline_step.to_step(row)
|
54
61
|
step.describe_to(visitor)
|
55
62
|
end
|
@@ -57,7 +64,7 @@ module Cucumber
|
|
57
64
|
|
58
65
|
context "when the step has a DocString" do
|
59
66
|
let(:location) { double }
|
60
|
-
let(:outline_step) { OutlineStep.new(node, language, location, keyword, name, doc_string) }
|
67
|
+
let(:outline_step) { OutlineStep.new(node, language, location, comments, keyword, name, doc_string) }
|
61
68
|
let(:doc_string) { DocString.new('a <arg> that needs replacing', '', location) }
|
62
69
|
let(:name) { 'anything' }
|
63
70
|
|
@@ -67,7 +74,7 @@ module Cucumber
|
|
67
74
|
expect( visitor ).to receive(:doc_string) do |doc_string|
|
68
75
|
expect( doc_string.content ).to eq "a replacement that needs replacing"
|
69
76
|
end
|
70
|
-
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language)
|
77
|
+
row = ExamplesTable::Row.new({'arg' => 'replacement'}, 1, location, language, comments)
|
71
78
|
step = outline_step.to_step(row)
|
72
79
|
step.describe_to(visitor)
|
73
80
|
end
|
@@ -6,9 +6,9 @@ module Cucumber
|
|
6
6
|
module Ast
|
7
7
|
describe Step do
|
8
8
|
let(:step) do
|
9
|
-
node, language, location, keyword, name = *double
|
9
|
+
node, language, location, comments, keyword, name = *double
|
10
10
|
multiline_arg = EmptyMultilineArgument.new
|
11
|
-
Step.new(node, language, location, keyword, name, multiline_arg)
|
11
|
+
Step.new(node, language, location, comments, keyword, name, multiline_arg)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "describing itself" do
|
@@ -27,7 +27,7 @@ module Cucumber
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with a multiline argument" do
|
30
|
-
let(:step) { Step.new(double, double, double, double, double, multiline_arg) }
|
30
|
+
let(:step) { Step.new(double, double, double, double, double, double, multiline_arg) }
|
31
31
|
let(:multiline_arg) { double }
|
32
32
|
|
33
33
|
it "tells its multiline argument to describe itself" do
|
@@ -39,8 +39,14 @@ module Cucumber
|
|
39
39
|
|
40
40
|
end
|
41
41
|
|
42
|
+
describe 'comments' do
|
43
|
+
it "has comments" do
|
44
|
+
expect( step ).to respond_to(:comments)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
42
48
|
describe "backtrace line" do
|
43
|
-
let(:step) { Step.new(double, double, "path/file.feature:10", "Given ", "this step passes", double) }
|
49
|
+
let(:step) { Step.new(double, double, "path/file.feature:10", double, "Given ", "this step passes", double) }
|
44
50
|
|
45
51
|
it "knows how to form the backtrace line" do
|
46
52
|
expect( step.backtrace_line ).to eq("path/file.feature:10:in `Given this step passes'")
|
@@ -52,9 +58,9 @@ module Cucumber
|
|
52
58
|
let(:language) { ::Gherkin::I18n.get('en') }
|
53
59
|
|
54
60
|
context "for keywords 'given', 'when' and 'then'" do
|
55
|
-
let(:given_step) { Step.new(double, language, double, "Given ", double, double) }
|
56
|
-
let(:when_step) { Step.new(double, language, double, "When ", double, double) }
|
57
|
-
let(:then_step) { Step.new(double, language, double, "Then ", double, double) }
|
61
|
+
let(:given_step) { Step.new(double, language, double, double, "Given ", double, double) }
|
62
|
+
let(:when_step) { Step.new(double, language, double, double, "When ", double, double) }
|
63
|
+
let(:then_step) { Step.new(double, language, double, double, "Then ", double, double) }
|
58
64
|
|
59
65
|
it "returns the keyword itself" do
|
60
66
|
expect( given_step.actual_keyword(nil) ).to eq("Given ")
|
@@ -64,9 +70,9 @@ module Cucumber
|
|
64
70
|
end
|
65
71
|
|
66
72
|
context "for keyword 'and', 'but', and '*'" do
|
67
|
-
let(:and_step) { Step.new(double, language, double, "And ", double, double) }
|
68
|
-
let(:but_step) { Step.new(double, language, double, "But ", double, double) }
|
69
|
-
let(:asterisk_step) { Step.new(double, language, double, "* ", double, double) }
|
73
|
+
let(:and_step) { Step.new(double, language, double, double, "And ", double, double) }
|
74
|
+
let(:but_step) { Step.new(double, language, double, double, "But ", double, double) }
|
75
|
+
let(:asterisk_step) { Step.new(double, language, double, double, "* ", double, double) }
|
70
76
|
|
71
77
|
context "when the previous step keyword exist" do
|
72
78
|
it "returns the previous step keyword" do
|
@@ -88,7 +94,7 @@ module Cucumber
|
|
88
94
|
|
89
95
|
context "for i18n languages" do
|
90
96
|
let(:language) { ::Gherkin::I18n.get('en-lol') }
|
91
|
-
let(:and_step) { Step.new(double, language, double, "AN ", double, double) }
|
97
|
+
let(:and_step) { Step.new(double, language, double, double, "AN ", double, double) }
|
92
98
|
|
93
99
|
it "returns the keyword in the correct language" do
|
94
100
|
expect( and_step.actual_keyword(nil) ).to eq("I CAN HAZ ")
|
@@ -101,8 +107,9 @@ module Cucumber
|
|
101
107
|
let(:outline_step) { double }
|
102
108
|
let(:step) do
|
103
109
|
node, language, location, keyword, name = *double
|
110
|
+
comments = []
|
104
111
|
multiline_arg = EmptyMultilineArgument.new
|
105
|
-
ExpandedOutlineStep.new(outline_step, node, language, location, keyword, name, multiline_arg)
|
112
|
+
ExpandedOutlineStep.new(outline_step, node, language, location, comments, keyword, name, multiline_arg)
|
106
113
|
end
|
107
114
|
|
108
115
|
describe "describing itself" do
|
@@ -121,7 +128,7 @@ module Cucumber
|
|
121
128
|
end
|
122
129
|
|
123
130
|
context "with a multiline argument" do
|
124
|
-
let(:step) {
|
131
|
+
let(:step) { ExpandedOutlineStep.new(double, double, double, double, double, double, double, multiline_arg) }
|
125
132
|
let(:multiline_arg) { double }
|
126
133
|
|
127
134
|
it "tells its multiline argument to describe itself" do
|
@@ -133,6 +140,12 @@ module Cucumber
|
|
133
140
|
|
134
141
|
end
|
135
142
|
|
143
|
+
describe 'comments' do
|
144
|
+
it "has comments" do
|
145
|
+
expect( step ).to respond_to(:comments)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
136
149
|
describe "matching location" do
|
137
150
|
let(:location) { double }
|
138
151
|
|
@@ -144,8 +157,8 @@ module Cucumber
|
|
144
157
|
end
|
145
158
|
|
146
159
|
describe "backtrace line" do
|
147
|
-
let(:outline_step) { OutlineStep.new(double, double, "path/file.feature:5", "Given ", "this step <state>", double) }
|
148
|
-
let(:step) { ExpandedOutlineStep.new(outline_step, double, double, "path/file.feature:10", "Given ", "this step passes", double) }
|
160
|
+
let(:outline_step) { OutlineStep.new(double, double, "path/file.feature:5", double, "Given ", "this step <state>", double) }
|
161
|
+
let(:step) { ExpandedOutlineStep.new(outline_step, double, double, "path/file.feature:10", double, "Given ", "this step passes", double) }
|
149
162
|
|
150
163
|
it "includes the outline step in the backtrace line" do
|
151
164
|
expect( step.backtrace_line ).to eq("path/file.feature:10:in `Given this step passes'\n" +
|
@@ -13,6 +13,28 @@ module Cucumber
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
context "location" do
|
17
|
+
|
18
|
+
context "with location passed to the constructor" do
|
19
|
+
let(:location) { double }
|
20
|
+
|
21
|
+
it "returns the location passed to the constructor" do
|
22
|
+
action = Action.new(location) {}
|
23
|
+
expect( action.location ).to be location
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "without location passed to the constructor" do
|
28
|
+
let(:block) { proc {} }
|
29
|
+
|
30
|
+
it "returns the location of the block passed to the constructor" do
|
31
|
+
action = Action.new(&block)
|
32
|
+
expect( action.location ).to eq Ast::Location.new(*block.source_location)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
16
38
|
context "executing" do
|
17
39
|
it "executes the block passed to the constructor" do
|
18
40
|
executed = false
|
@@ -105,9 +127,16 @@ module Cucumber
|
|
105
127
|
end
|
106
128
|
|
107
129
|
describe UndefinedAction do
|
108
|
-
let(:
|
130
|
+
let(:location) { double }
|
131
|
+
let(:action) { UndefinedAction.new(location) }
|
109
132
|
let(:test_step) { double }
|
110
133
|
|
134
|
+
context "location" do
|
135
|
+
it "returns the location passed to the constructor" do
|
136
|
+
expect( action.location ).to be location
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
111
140
|
context "executing" do
|
112
141
|
it "returns an undefined result" do
|
113
142
|
expect( action.execute ).to be_undefined
|
@@ -30,11 +30,25 @@ module Cucumber::Core::Test
|
|
30
30
|
expect { Result::Passed.new }.to raise_error(ArgumentError)
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
it
|
33
|
+
it "does nothing when appending the backtrace" do
|
34
|
+
expect( result.with_appended_backtrace(double) ).to equal result
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does nothing when filtering the backtrace" do
|
38
|
+
expect( result.with_filtered_backtrace(double) ).to equal result
|
39
|
+
end
|
40
|
+
|
41
|
+
specify { expect( result.to_sym ).to eq :passed }
|
42
|
+
|
43
|
+
specify { expect( result ).to be_passed }
|
44
|
+
specify { expect( result ).not_to be_failed }
|
45
|
+
specify { expect( result ).not_to be_undefined }
|
46
|
+
specify { expect( result ).not_to be_unknown }
|
47
|
+
specify { expect( result ).not_to be_skipped }
|
48
|
+
|
49
|
+
specify { expect( result ).to be_ok }
|
50
|
+
specify { expect( result.ok?(false) ).to be_truthy }
|
51
|
+
specify { expect( result.ok?(true) ).to be_truthy }
|
38
52
|
end
|
39
53
|
|
40
54
|
describe Result::Failed do
|
@@ -58,11 +72,42 @@ module Cucumber::Core::Test
|
|
58
72
|
expect { Result::Failed.new(duration) }.to raise_error(ArgumentError)
|
59
73
|
end
|
60
74
|
|
61
|
-
it
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
it "does nothing if step has no backtrace line" do
|
76
|
+
result.exception.set_backtrace("exception backtrace")
|
77
|
+
step = "does not respond_to?(:backtrace_line)"
|
78
|
+
|
79
|
+
expect( result.with_appended_backtrace(step).exception.backtrace ).to eq(["exception backtrace"])
|
80
|
+
end
|
81
|
+
|
82
|
+
it "appends the backtrace line of the step" do
|
83
|
+
result.exception.set_backtrace("exception backtrace")
|
84
|
+
step = double
|
85
|
+
expect( step ).to receive(:backtrace_line).and_return("step_line")
|
86
|
+
|
87
|
+
expect( result.with_appended_backtrace(step).exception.backtrace ).to eq(["exception backtrace", "step_line"])
|
88
|
+
end
|
89
|
+
|
90
|
+
it "apply filters to the exception" do
|
91
|
+
filter_class = double
|
92
|
+
filter = double
|
93
|
+
filtered_exception = double
|
94
|
+
expect( filter_class ).to receive(:new).with(result.exception).and_return(filter)
|
95
|
+
expect( filter ).to receive(:exception).and_return(filtered_exception)
|
96
|
+
|
97
|
+
expect( result.with_filtered_backtrace(filter_class).exception ).to equal filtered_exception
|
98
|
+
end
|
99
|
+
|
100
|
+
specify { expect( result.to_sym ).to eq :failed }
|
101
|
+
|
102
|
+
specify { expect( result ).not_to be_passed }
|
103
|
+
specify { expect( result ).to be_failed }
|
104
|
+
specify { expect( result ).not_to be_undefined }
|
105
|
+
specify { expect( result ).not_to be_unknown }
|
106
|
+
specify { expect( result ).not_to be_skipped }
|
107
|
+
|
108
|
+
specify { expect( result ).to_not be_ok }
|
109
|
+
specify { expect( result.ok?(false) ).to be_falsey }
|
110
|
+
specify { expect( result.ok?(true) ).to be_falsey }
|
66
111
|
end
|
67
112
|
|
68
113
|
describe Result::Unknown do
|
@@ -73,11 +118,61 @@ module Cucumber::Core::Test
|
|
73
118
|
result.describe_to(visitor, args)
|
74
119
|
end
|
75
120
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
121
|
+
specify { expect( result.to_sym ).to eq :unknown }
|
122
|
+
|
123
|
+
specify { expect( result ).not_to be_passed }
|
124
|
+
specify { expect( result ).not_to be_failed }
|
125
|
+
specify { expect( result ).not_to be_undefined }
|
126
|
+
specify { expect( result ).to be_unknown }
|
127
|
+
specify { expect( result ).not_to be_skipped }
|
128
|
+
end
|
129
|
+
|
130
|
+
describe Result::Raisable do
|
131
|
+
context "with or without backtrace" do
|
132
|
+
subject(:result) { Result::Raisable.new }
|
133
|
+
|
134
|
+
it "does nothing if step has no backtrace line" do
|
135
|
+
step = "does not respond_to?(:backtrace_line)"
|
136
|
+
|
137
|
+
expect( result.with_appended_backtrace(step).backtrace ).to eq(nil)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "without backtrace" do
|
142
|
+
subject(:result) { Result::Raisable.new }
|
143
|
+
|
144
|
+
it "set the backtrace to the backtrace line of the step" do
|
145
|
+
step = double
|
146
|
+
expect( step ).to receive(:backtrace_line).and_return("step_line")
|
147
|
+
|
148
|
+
expect( result.with_appended_backtrace(step).backtrace ).to eq(["step_line"])
|
149
|
+
end
|
150
|
+
|
151
|
+
it "does nothing when filtering the backtrace" do
|
152
|
+
expect( result.with_filtered_backtrace(double) ).to equal result
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "with backtrace" do
|
157
|
+
subject(:result) { Result::Raisable.new("message", 0, "backtrace") }
|
158
|
+
|
159
|
+
it "appends the backtrace line of the step" do
|
160
|
+
step = double
|
161
|
+
expect( step ).to receive(:backtrace_line).and_return("step_line")
|
162
|
+
|
163
|
+
expect( result.with_appended_backtrace(step).backtrace ).to eq(["backtrace", "step_line"])
|
164
|
+
end
|
165
|
+
|
166
|
+
it "apply filters to the backtrace" do
|
167
|
+
filter_class = double
|
168
|
+
filter = double
|
169
|
+
filtered_result = double
|
170
|
+
expect( filter_class ).to receive(:new).with(result.exception).and_return(filter)
|
171
|
+
expect( filter ).to receive(:exception).and_return(filtered_result)
|
172
|
+
|
173
|
+
expect( result.with_filtered_backtrace(filter_class) ).to equal filtered_result
|
174
|
+
end
|
175
|
+
end
|
81
176
|
end
|
82
177
|
|
83
178
|
describe Result::Undefined do
|
@@ -89,11 +184,17 @@ module Cucumber::Core::Test
|
|
89
184
|
result.describe_to(visitor, args)
|
90
185
|
end
|
91
186
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
187
|
+
specify { expect( result.to_sym ).to eq :undefined }
|
188
|
+
|
189
|
+
specify { expect( result ).not_to be_passed }
|
190
|
+
specify { expect( result ).not_to be_failed }
|
191
|
+
specify { expect( result ).to be_undefined }
|
192
|
+
specify { expect( result ).not_to be_unknown }
|
193
|
+
specify { expect( result ).not_to be_skipped }
|
194
|
+
|
195
|
+
specify { expect( result ).to be_ok }
|
196
|
+
specify { expect( result.ok?(false) ).to be_truthy }
|
197
|
+
specify { expect( result.ok?(true) ).to be_falsey }
|
97
198
|
end
|
98
199
|
|
99
200
|
describe Result::Skipped do
|
@@ -105,11 +206,40 @@ module Cucumber::Core::Test
|
|
105
206
|
result.describe_to(visitor, args)
|
106
207
|
end
|
107
208
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
209
|
+
specify { expect( result.to_sym ).to eq :skipped }
|
210
|
+
|
211
|
+
specify { expect( result ).not_to be_passed }
|
212
|
+
specify { expect( result ).not_to be_failed }
|
213
|
+
specify { expect( result ).not_to be_undefined }
|
214
|
+
specify { expect( result ).not_to be_unknown }
|
215
|
+
specify { expect( result ).to be_skipped }
|
216
|
+
|
217
|
+
specify { expect( result ).to be_ok }
|
218
|
+
specify { expect( result.ok?(false) ).to be_truthy }
|
219
|
+
specify { expect( result.ok?(true) ).to be_truthy }
|
220
|
+
end
|
221
|
+
|
222
|
+
describe Result::Pending do
|
223
|
+
subject(:result) { Result::Pending.new }
|
224
|
+
|
225
|
+
it "describes itself to a visitor" do
|
226
|
+
expect( visitor ).to receive(:pending).with(result, args)
|
227
|
+
expect( visitor ).to receive(:duration).with(an_unknown_duration, args)
|
228
|
+
result.describe_to(visitor, args)
|
229
|
+
end
|
230
|
+
|
231
|
+
specify { expect( result.to_sym ).to eq :pending }
|
232
|
+
|
233
|
+
specify { expect( result ).not_to be_passed }
|
234
|
+
specify { expect( result ).not_to be_failed }
|
235
|
+
specify { expect( result ).not_to be_undefined }
|
236
|
+
specify { expect( result ).not_to be_unknown }
|
237
|
+
specify { expect( result ).not_to be_skipped }
|
238
|
+
specify { expect( result ).to be_pending }
|
239
|
+
|
240
|
+
specify { expect( result ).to be_ok }
|
241
|
+
specify { expect( result.ok?(false) ).to be_truthy }
|
242
|
+
specify { expect( result.ok?(true) ).to be_falsey }
|
113
243
|
end
|
114
244
|
|
115
245
|
describe Result::Summary do
|