cucumber-core 1.0.0.beta.2 → 1.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cucumber/core.rb +0 -1
- data/lib/cucumber/core/ast.rb +0 -1
- data/lib/cucumber/core/ast/data_table.rb +8 -223
- data/lib/cucumber/core/ast/examples_table.rb +2 -6
- data/lib/cucumber/core/ast/feature.rb +3 -8
- data/lib/cucumber/core/ast/location.rb +12 -8
- data/lib/cucumber/core/ast/outline_step.rb +4 -11
- data/lib/cucumber/core/ast/scenario_outline.rb +2 -6
- data/lib/cucumber/core/ast/step.rb +28 -7
- data/lib/cucumber/core/gherkin/ast_builder.rb +36 -23
- data/lib/cucumber/core/test/{mapping.rb → action.rb} +10 -11
- data/lib/cucumber/core/test/mapper.rb +3 -3
- data/lib/cucumber/core/test/runner.rb +2 -2
- data/lib/cucumber/core/test/step.rb +7 -7
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/cucumber/core/ast/data_table_spec.rb +5 -92
- data/spec/cucumber/core/ast/location_spec.rb +8 -0
- data/spec/cucumber/core/ast/outline_step_spec.rb +4 -9
- data/spec/cucumber/core/ast/step_spec.rb +70 -3
- data/spec/cucumber/core/test/{mapping_spec.rb → action_spec.rb} +36 -27
- data/spec/cucumber/core/test/mapper_spec.rb +13 -12
- data/spec/cucumber/core/test/runner_spec.rb +14 -0
- data/spec/cucumber/core/test/step_spec.rb +4 -3
- data/spec/cucumber/core_spec.rb +4 -4
- metadata +6 -8
- data/lib/cucumber/core/ast/multiline_argument.rb +0 -34
- data/lib/cucumber/core/test/filters/debug_filter.rb +0 -28
@@ -1,58 +1,66 @@
|
|
1
|
-
require 'cucumber/core/test/
|
1
|
+
require 'cucumber/core/test/action'
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module Core
|
5
5
|
module Test
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Action do
|
8
|
+
let(:last_result) { double('last_result') }
|
8
9
|
|
9
10
|
context "constructed without a block" do
|
10
11
|
it "raises an error" do
|
11
|
-
expect {
|
12
|
+
expect { Action.new }.to raise_error(ArgumentError)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
context "executing" do
|
16
17
|
it "executes the block passed to the constructor" do
|
17
18
|
executed = false
|
18
|
-
mapping =
|
19
|
-
mapping.execute
|
19
|
+
mapping = Action.new { executed = true }
|
20
|
+
mapping.execute(last_result)
|
20
21
|
expect( executed ).to be_truthy
|
21
22
|
end
|
22
23
|
|
23
24
|
it "returns a passed result if the block doesn't fail" do
|
24
|
-
mapping =
|
25
|
-
expect( mapping.execute ).to be_passed
|
25
|
+
mapping = Action.new {}
|
26
|
+
expect( mapping.execute(last_result) ).to be_passed
|
26
27
|
end
|
27
28
|
|
28
29
|
it "returns a failed result when the block raises an error" do
|
29
30
|
exception = StandardError.new
|
30
|
-
mapping =
|
31
|
-
result = mapping.execute
|
31
|
+
mapping = Action.new { raise exception }
|
32
|
+
result = mapping.execute(last_result)
|
32
33
|
expect( result ).to be_failed
|
33
34
|
expect( result.exception ).to eq exception
|
34
35
|
end
|
35
36
|
|
37
|
+
it "yields the last_result to the block" do
|
38
|
+
last_result_spy = nil
|
39
|
+
mapping = Action.new { |last_result| last_result_spy = last_result }
|
40
|
+
mapping.execute(last_result)
|
41
|
+
expect(last_result_spy).to eq last_result
|
42
|
+
end
|
43
|
+
|
36
44
|
it "returns a pending result if a Result::Pending error is raised" do
|
37
45
|
exception = Result::Pending.new("TODO")
|
38
|
-
mapping =
|
39
|
-
result = mapping.execute
|
46
|
+
mapping = Action.new { raise exception }
|
47
|
+
result = mapping.execute(last_result)
|
40
48
|
expect( result ).to be_pending
|
41
49
|
expect( result.message ).to eq "TODO"
|
42
50
|
end
|
43
51
|
|
44
52
|
it "returns a skipped result if a Result::Skipped error is raised" do
|
45
53
|
exception = Result::Skipped.new("Not working right now")
|
46
|
-
mapping =
|
47
|
-
result = mapping.execute
|
54
|
+
mapping = Action.new { raise exception }
|
55
|
+
result = mapping.execute(last_result)
|
48
56
|
expect( result ).to be_skipped
|
49
57
|
expect( result.message ).to eq "Not working right now"
|
50
58
|
end
|
51
59
|
|
52
60
|
it "returns an undefined result if a Result::Undefined error is raised" do
|
53
61
|
exception = Result::Undefined.new("new step")
|
54
|
-
mapping =
|
55
|
-
result = mapping.execute
|
62
|
+
mapping = Action.new { raise exception }
|
63
|
+
result = mapping.execute(last_result)
|
56
64
|
expect( result ).to be_undefined
|
57
65
|
expect( result.message ).to eq "new step"
|
58
66
|
end
|
@@ -66,14 +74,14 @@ module Cucumber
|
|
66
74
|
end
|
67
75
|
|
68
76
|
it "records the nanoseconds duration of the execution on the result" do
|
69
|
-
mapping =
|
70
|
-
duration = mapping.execute.duration
|
77
|
+
mapping = Action.new { }
|
78
|
+
duration = mapping.execute(last_result).duration
|
71
79
|
expect( duration ).to eq 1
|
72
80
|
end
|
73
81
|
|
74
82
|
it "records the duration of a failed execution" do
|
75
|
-
mapping =
|
76
|
-
duration = mapping.execute.duration
|
83
|
+
mapping = Action.new { raise StandardError }
|
84
|
+
duration = mapping.execute(last_result).duration
|
77
85
|
expect( duration ).to eq 1
|
78
86
|
end
|
79
87
|
end
|
@@ -83,31 +91,32 @@ module Cucumber
|
|
83
91
|
context "skipping" do
|
84
92
|
it "does not execute the block" do
|
85
93
|
executed = false
|
86
|
-
mapping =
|
87
|
-
mapping.skip
|
94
|
+
mapping = Action.new { executed = true }
|
95
|
+
mapping.skip(last_result)
|
88
96
|
expect( executed ).to be_falsey
|
89
97
|
end
|
90
98
|
|
91
99
|
it "returns a skipped result" do
|
92
|
-
mapping =
|
93
|
-
expect( mapping.skip ).to be_skipped
|
100
|
+
mapping = Action.new {}
|
101
|
+
expect( mapping.skip(last_result) ).to be_skipped
|
94
102
|
end
|
95
103
|
end
|
96
104
|
end
|
97
105
|
|
98
|
-
describe
|
99
|
-
let(:mapping) {
|
106
|
+
describe UndefinedAction do
|
107
|
+
let(:mapping) { UndefinedAction.new }
|
100
108
|
let(:test_step) { double }
|
109
|
+
let(:last_result) { double('last_result') }
|
101
110
|
|
102
111
|
context "executing" do
|
103
112
|
it "returns an undefined result" do
|
104
|
-
expect( mapping.execute ).to be_undefined
|
113
|
+
expect( mapping.execute(last_result) ).to be_undefined
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
108
117
|
context "skipping" do
|
109
118
|
it "returns an undefined result" do
|
110
|
-
expect( mapping.skip ).to be_undefined
|
119
|
+
expect( mapping.skip(last_result) ).to be_undefined
|
111
120
|
end
|
112
121
|
end
|
113
122
|
|
@@ -17,11 +17,12 @@ module Cucumber
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
let(:mapper)
|
21
|
-
let(:receiver)
|
22
|
-
before
|
23
|
-
let(:mappings)
|
24
|
-
let(:app)
|
20
|
+
let(:mapper) { Mapper.new(mappings, receiver) }
|
21
|
+
let(:receiver) { double('receiver') }
|
22
|
+
before { allow(receiver).to receive(:test_case).and_yield(receiver) }
|
23
|
+
let(:mappings) { ExampleMappings.new(app) }
|
24
|
+
let(:app) { double('app') }
|
25
|
+
let(:last_result) { double('last_result') }
|
25
26
|
|
26
27
|
context "an unmapped step" do
|
27
28
|
let(:test_step) { Test::Step.new([double(name: 'unmapped')]) }
|
@@ -30,7 +31,7 @@ module Cucumber
|
|
30
31
|
it "maps to a step that executes to an undefined result" do
|
31
32
|
expect( receiver ).to receive(:test_step) do |test_step|
|
32
33
|
expect( test_step.name ).to eq 'unmapped'
|
33
|
-
expect( test_step.execute ).to be_undefined
|
34
|
+
expect( test_step.execute(last_result) ).to be_undefined
|
34
35
|
end.once.ordered
|
35
36
|
test_case.describe_to mapper
|
36
37
|
end
|
@@ -44,7 +45,7 @@ module Cucumber
|
|
44
45
|
expect( receiver ).to receive(:test_step) do |test_step|
|
45
46
|
expect( test_step.name ).to eq 'mapped'
|
46
47
|
expect( app ).to receive(:do_something)
|
47
|
-
test_step.execute
|
48
|
+
test_step.execute(last_result)
|
48
49
|
end.once.ordered
|
49
50
|
test_case.describe_to mapper
|
50
51
|
end
|
@@ -68,7 +69,7 @@ module Cucumber
|
|
68
69
|
|
69
70
|
context "mapping hooks" do
|
70
71
|
let(:test_case) { Case.new([test_step], source) }
|
71
|
-
let(:test_step) { Step.new([Ast::Step.new(:language, :location, :keyword, :name, :multiline_arg)]) }
|
72
|
+
let(:test_step) { Step.new([Ast::Step.new(:node, :language, :location, :keyword, :name, :multiline_arg)]) }
|
72
73
|
let(:source) { [feature, scenario] }
|
73
74
|
let(:feature) { double('feature') }
|
74
75
|
let(:scenario) { double('scenario', location: 'test') }
|
@@ -108,7 +109,7 @@ module Cucumber
|
|
108
109
|
|
109
110
|
allow(receiver).to receive(:test_case).and_yield(receiver)
|
110
111
|
allow(receiver).to receive(:test_step) do |test_step|
|
111
|
-
test_step.execute
|
112
|
+
test_step.execute(last_result)
|
112
113
|
end
|
113
114
|
|
114
115
|
test_case.describe_to mapper
|
@@ -127,7 +128,7 @@ module Cucumber
|
|
127
128
|
expect( scenario ).to receive(:describe_to)
|
128
129
|
expect( visitor ).to receive(:before_hook) do |hook, hook_args|
|
129
130
|
expect( args ).to eq(hook_args)
|
130
|
-
expect( hook.location.to_s ).to eq("#{__FILE__}:
|
131
|
+
expect( hook.location.to_s ).to eq("#{__FILE__}:121")
|
131
132
|
end
|
132
133
|
test_step.describe_source_to(visitor, args)
|
133
134
|
end
|
@@ -147,7 +148,7 @@ module Cucumber
|
|
147
148
|
expect( scenario ).to receive(:describe_to)
|
148
149
|
expect( visitor ).to receive(:after_hook) do |hook, hook_args|
|
149
150
|
expect( args ).to eq(hook_args)
|
150
|
-
expect( hook.location.to_s ).to eq("#{__FILE__}:
|
151
|
+
expect( hook.location.to_s ).to eq("#{__FILE__}:141")
|
151
152
|
end
|
152
153
|
test_step.describe_source_to(visitor, args)
|
153
154
|
end
|
@@ -167,7 +168,7 @@ module Cucumber
|
|
167
168
|
expect( visitor ).to receive(:step).ordered
|
168
169
|
expect( visitor ).to receive(:after_step_hook) do |hook, hook_args|
|
169
170
|
expect( args ).to eq(hook_args)
|
170
|
-
expect( hook.location.to_s ).to eq("#{__FILE__}:
|
171
|
+
expect( hook.location.to_s ).to eq("#{__FILE__}:160")
|
171
172
|
end.once.ordered
|
172
173
|
expect( visitor ).to receive(:step).ordered
|
173
174
|
test_case.describe_to mapper
|
@@ -195,5 +195,19 @@ module Cucumber::Core::Test
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
+
context "passing latest result to a mapping" do
|
199
|
+
it "passes a Failed result when the scenario is failing" do
|
200
|
+
result_spy = nil
|
201
|
+
hook_mapping = UnskippableAction.new do |last_result|
|
202
|
+
result_spy = last_result
|
203
|
+
end
|
204
|
+
after_hook = Step.new([double], hook_mapping)
|
205
|
+
failing_step = Step.new([double]).with_mapping { fail }
|
206
|
+
test_case = Case.new([failing_step, after_hook], source)
|
207
|
+
test_case.describe_to runner
|
208
|
+
expect(result_spy).to be_failed
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
198
212
|
end
|
199
213
|
end
|
@@ -2,6 +2,7 @@ require 'cucumber/core/test/step'
|
|
2
2
|
|
3
3
|
module Cucumber::Core::Test
|
4
4
|
describe Step do
|
5
|
+
let(:last_result) { double('last_result') }
|
5
6
|
|
6
7
|
describe "describing itself" do
|
7
8
|
it "describes itself to a visitor" do
|
@@ -30,7 +31,7 @@ module Cucumber::Core::Test
|
|
30
31
|
context "when a passing mapping exists" do
|
31
32
|
it "returns a passing result" do
|
32
33
|
test_step = Step.new([ast_step]).with_mapping {}
|
33
|
-
expect( test_step.execute ).to be_passed
|
34
|
+
expect( test_step.execute(last_result) ).to be_passed
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -39,7 +40,7 @@ module Cucumber::Core::Test
|
|
39
40
|
|
40
41
|
it "returns a failing result" do
|
41
42
|
test_step = Step.new([ast_step]).with_mapping { raise exception }
|
42
|
-
result = test_step.execute
|
43
|
+
result = test_step.execute(last_result)
|
43
44
|
expect( result ).to be_failed
|
44
45
|
expect( result.exception ).to eq exception
|
45
46
|
end
|
@@ -48,7 +49,7 @@ module Cucumber::Core::Test
|
|
48
49
|
context "with no mapping" do
|
49
50
|
it "returns an Undefined result" do
|
50
51
|
test_step = Step.new([ast_step])
|
51
|
-
result = test_step.execute
|
52
|
+
result = test_step.execute(last_result)
|
52
53
|
expect( result ).to be_undefined
|
53
54
|
end
|
54
55
|
end
|
data/spec/cucumber/core_spec.rb
CHANGED
@@ -297,17 +297,17 @@ module Cucumber
|
|
297
297
|
|
298
298
|
def test_case(test_case, mapper)
|
299
299
|
mapper.before { @logger << ['--'] }
|
300
|
-
failing_before =
|
300
|
+
failing_before = proc do
|
301
301
|
@logger << [:failing_before, test_case.name]
|
302
302
|
raise Failure
|
303
303
|
end
|
304
|
-
passing_after =
|
304
|
+
passing_after = proc do
|
305
305
|
@logger << [:passing_after, test_case.name]
|
306
306
|
end
|
307
|
-
passing_before =
|
307
|
+
passing_before = proc do
|
308
308
|
@logger << [:passing_before, test_case.name]
|
309
309
|
end
|
310
|
-
failing_after =
|
310
|
+
failing_after = proc do
|
311
311
|
@logger << [:failing_after, test_case.name]
|
312
312
|
raise Failure
|
313
313
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: gherkin
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- lib/cucumber/core/ast/examples_table.rb
|
126
126
|
- lib/cucumber/core/ast/feature.rb
|
127
127
|
- lib/cucumber/core/ast/location.rb
|
128
|
-
- lib/cucumber/core/ast/multiline_argument.rb
|
129
128
|
- lib/cucumber/core/ast/names.rb
|
130
129
|
- lib/cucumber/core/ast/outline_step.rb
|
131
130
|
- lib/cucumber/core/ast/scenario.rb
|
@@ -139,13 +138,12 @@ files:
|
|
139
138
|
- lib/cucumber/core/gherkin/writer.rb
|
140
139
|
- lib/cucumber/core/gherkin/writer/helpers.rb
|
141
140
|
- lib/cucumber/core/platform.rb
|
141
|
+
- lib/cucumber/core/test/action.rb
|
142
142
|
- lib/cucumber/core/test/case.rb
|
143
143
|
- lib/cucumber/core/test/filters.rb
|
144
|
-
- lib/cucumber/core/test/filters/debug_filter.rb
|
145
144
|
- lib/cucumber/core/test/filters/tag_filter.rb
|
146
145
|
- lib/cucumber/core/test/hooks.rb
|
147
146
|
- lib/cucumber/core/test/mapper.rb
|
148
|
-
- lib/cucumber/core/test/mapping.rb
|
149
147
|
- lib/cucumber/core/test/result.rb
|
150
148
|
- lib/cucumber/core/test/runner.rb
|
151
149
|
- lib/cucumber/core/test/step.rb
|
@@ -163,10 +161,10 @@ files:
|
|
163
161
|
- spec/cucumber/core/compiler_spec.rb
|
164
162
|
- spec/cucumber/core/gherkin/parser_spec.rb
|
165
163
|
- spec/cucumber/core/gherkin/writer_spec.rb
|
164
|
+
- spec/cucumber/core/test/action_spec.rb
|
166
165
|
- spec/cucumber/core/test/case_spec.rb
|
167
166
|
- spec/cucumber/core/test/hooks_spec.rb
|
168
167
|
- spec/cucumber/core/test/mapper_spec.rb
|
169
|
-
- spec/cucumber/core/test/mapping_spec.rb
|
170
168
|
- spec/cucumber/core/test/result_spec.rb
|
171
169
|
- spec/cucumber/core/test/runner_spec.rb
|
172
170
|
- spec/cucumber/core/test/step_spec.rb
|
@@ -198,7 +196,7 @@ rubyforge_project:
|
|
198
196
|
rubygems_version: 2.0.14
|
199
197
|
signing_key:
|
200
198
|
specification_version: 4
|
201
|
-
summary: cucumber-core-1.0.0.beta.
|
199
|
+
summary: cucumber-core-1.0.0.beta.3
|
202
200
|
test_files:
|
203
201
|
- spec/capture_warnings.rb
|
204
202
|
- spec/coverage.rb
|
@@ -211,10 +209,10 @@ test_files:
|
|
211
209
|
- spec/cucumber/core/compiler_spec.rb
|
212
210
|
- spec/cucumber/core/gherkin/parser_spec.rb
|
213
211
|
- spec/cucumber/core/gherkin/writer_spec.rb
|
212
|
+
- spec/cucumber/core/test/action_spec.rb
|
214
213
|
- spec/cucumber/core/test/case_spec.rb
|
215
214
|
- spec/cucumber/core/test/hooks_spec.rb
|
216
215
|
- spec/cucumber/core/test/mapper_spec.rb
|
217
|
-
- spec/cucumber/core/test/mapping_spec.rb
|
218
216
|
- spec/cucumber/core/test/result_spec.rb
|
219
217
|
- spec/cucumber/core/test/runner_spec.rb
|
220
218
|
- spec/cucumber/core/test/step_spec.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'gherkin/rubify'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Core
|
5
|
-
module Ast
|
6
|
-
module MultilineArgument
|
7
|
-
|
8
|
-
class << self
|
9
|
-
include Gherkin::Rubify
|
10
|
-
|
11
|
-
# TODO: move this up to the front-end
|
12
|
-
def from(argument, parent_location)
|
13
|
-
return EmptyMultilineArgument.new unless argument
|
14
|
-
return argument if argument.respond_to?(:to_step_definition_arg)
|
15
|
-
|
16
|
-
argument = rubify(argument)
|
17
|
-
case argument
|
18
|
-
when String
|
19
|
-
Ast::DocString.new(argument, 'text/plain', parent_location)
|
20
|
-
when ::Gherkin::Formatter::Model::DocString
|
21
|
-
Ast::DocString.new(argument.value, argument.content_type, parent_location.on_line(argument.line_range))
|
22
|
-
when Array
|
23
|
-
location = parent_location.on_line(argument.first.line..argument.last.line)
|
24
|
-
Ast::DataTable.new(argument.map{|row| row.cells}, location)
|
25
|
-
else
|
26
|
-
raise ArgumentError, "Don't know how to convert #{argument.inspect} into a MultilineArgument"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Core
|
3
|
-
module Test
|
4
|
-
class DebugFilter
|
5
|
-
def initialize(receiver)
|
6
|
-
@receiver = receiver
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_case(test_case, &descend)
|
10
|
-
p [:test_case, test_case.source.last.class, test_case.location.to_s]
|
11
|
-
descend.call(self)
|
12
|
-
test_case.describe_to @receiver
|
13
|
-
self
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_step(test_step)
|
17
|
-
p [:test_step, test_step.source.last.class, test_step.location.to_s]
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
def done
|
22
|
-
@receiver.done
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|