cucumber-core 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/HISTORY.md +12 -2
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/cucumber-core.gemspec +1 -1
- data/lib/cucumber/core/ast/feature.rb +22 -5
- data/lib/cucumber/core/gherkin/ast_builder.rb +38 -25
- data/lib/cucumber/core/gherkin/parser.rb +0 -4
- data/lib/cucumber/core/test/filters/activate_steps_for_self_test.rb +36 -0
- data/lib/cucumber/core/test/result.rb +6 -2
- data/lib/cucumber/core/test/timer.rb +20 -2
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/cucumber/core/gherkin/parser_spec.rb +1 -5
- data/spec/cucumber/core/test/action_spec.rb +1 -4
- data/spec/cucumber/core/test/result_spec.rb +19 -12
- data/spec/cucumber/core/test/runner_spec.rb +1 -4
- data/spec/cucumber/core/test/timer_spec.rb +2 -4
- data/spec/cucumber/core_spec.rb +2 -18
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1fc45a561bb99340344287c1e671c9cdfe5c3e7
|
4
|
+
data.tar.gz: 71d6d270193517dec221d7a61a557abae8bdbeb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39f345c74c57332f0022faaab37e74cbb6029d544551435a9ab0b2986af82c4c6c33f13554315bf5a01fe5e00760bedbcb131cc9454fceac38025933dd93e07d
|
7
|
+
data.tar.gz: 3dfc0894b9e62ecffc08f39b85acc0bfd4ddea7e5bda3ebd11a7fe164011a383e667abee3c0158268b2fcca35607c7c3bb433c338a8ddae731fb63248867ecad
|
data/.travis.yml
CHANGED
data/HISTORY.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.
|
1
|
+
## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.5.0...v1.x-bugfix)
|
2
2
|
|
3
3
|
### New Features
|
4
4
|
|
5
5
|
### Bugfixes
|
6
6
|
|
7
|
+
## [v1.5.0](https://github.com/cucumber/cucumber-ruby-core/compare/v1.4.0...v1.5.0)
|
8
|
+
|
9
|
+
### New Features
|
10
|
+
|
11
|
+
* Update to Gherkin v4.0 (@brasmusson)
|
12
|
+
|
13
|
+
### Bugfixes
|
14
|
+
|
15
|
+
* Use monotonic time ([#103](https://github.com/cucumber/cucumber-ruby-core/pull/103) @mikz)
|
16
|
+
|
7
17
|
## [v1.4.0](https://github.com/cucumber/cucumber-ruby-core/compare/v1.3.1...v1.4.0)
|
8
18
|
|
9
19
|
### New Features
|
@@ -18,7 +28,7 @@
|
|
18
28
|
|
19
29
|
### Bugfixes
|
20
30
|
|
21
|
-
* Speed up location filtering ([99](https://github.com/cucumber/cucumber-ruby-core/issues/99) @mattwynne @akostadinov @brasmusson)
|
31
|
+
* Speed up location filtering ([#99](https://github.com/cucumber/cucumber-ruby-core/issues/99) @mattwynne @akostadinov @brasmusson)
|
22
32
|
|
23
33
|
## [v1.3.0](https://github.com/cucumber/cucumber-ruby-core/compare/v1.2.0...v1.3.0)
|
24
34
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/cucumber-core.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = "MIT"
|
15
15
|
s.required_ruby_version = ">= 1.9.3"
|
16
16
|
|
17
|
-
s.add_dependency 'gherkin', '~>
|
17
|
+
s.add_dependency 'gherkin', '~> 4.0'
|
18
18
|
|
19
19
|
s.add_development_dependency 'bundler', '>= 1.3.5'
|
20
20
|
s.add_development_dependency 'rake', '>= 0.9.2'
|
@@ -16,20 +16,20 @@ module Cucumber
|
|
16
16
|
:comments, :tags, :keyword, :description,
|
17
17
|
:feature_elements
|
18
18
|
|
19
|
-
def initialize(language, location,
|
19
|
+
def initialize(language, location, comments, tags, keyword, name, description, feature_elements)
|
20
20
|
@language = language
|
21
21
|
@location = location
|
22
|
-
@background =
|
22
|
+
@background = BackgroundFinder.new(feature_elements).result
|
23
23
|
@comments = comments
|
24
24
|
@tags = tags
|
25
25
|
@keyword = keyword
|
26
26
|
@name = name
|
27
27
|
@description = description
|
28
|
-
@feature_elements =
|
28
|
+
@feature_elements = feature_elements
|
29
29
|
end
|
30
30
|
|
31
31
|
def children
|
32
|
-
|
32
|
+
@feature_elements
|
33
33
|
end
|
34
34
|
|
35
35
|
def short_name
|
@@ -47,7 +47,6 @@ module Cucumber
|
|
47
47
|
sexp += [comment] if comment
|
48
48
|
tags = @tags.to_sexp
|
49
49
|
sexp += tags if tags.any?
|
50
|
-
sexp += [@background.to_sexp] if @background
|
51
50
|
sexp += @feature_elements.map{|fe| fe.to_sexp}
|
52
51
|
sexp
|
53
52
|
end
|
@@ -66,6 +65,24 @@ module Cucumber
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
68
|
+
class BackgroundFinder
|
69
|
+
def initialize(feature_elements)
|
70
|
+
@background = nil
|
71
|
+
feature_elements[0].describe_to(self) unless feature_elements.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def background(background)
|
75
|
+
@background = background
|
76
|
+
end
|
77
|
+
|
78
|
+
def result
|
79
|
+
@background ? @background : EmptyBackground.new
|
80
|
+
end
|
81
|
+
|
82
|
+
def method_missing(*)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
69
86
|
require 'delegate'
|
70
87
|
class LanguageDelegator < SimpleDelegator
|
71
88
|
attr_reader :iso_code
|
@@ -13,7 +13,7 @@ module Cucumber
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def feature(attributes)
|
16
|
-
|
16
|
+
DocumentBuilder.new(file, attributes).feature
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -94,55 +94,68 @@ module Cucumber
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
class DocumentBuilder < Builder
|
98
|
+
def initialize(file, attributes)
|
99
|
+
@file = file
|
100
|
+
@attributes = rubify_keys(attributes.dup)
|
101
|
+
end
|
102
|
+
|
103
|
+
def feature
|
104
|
+
return Ast::NullFeature.new unless attributes[:feature]
|
105
|
+
feature_builder = FeatureBuilder.new(file, attributes[:feature])
|
106
|
+
feature_builder.handle_comments(all_comments)
|
107
|
+
feature_builder.result
|
108
|
+
end
|
109
|
+
|
110
|
+
def all_comments
|
111
|
+
attributes[:comments].map do |comment|
|
112
|
+
Ast::Comment.new(
|
113
|
+
Ast::Location.new(file, comment[:location][:line]),
|
114
|
+
comment[:text]
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
97
120
|
class FeatureBuilder < Builder
|
98
|
-
attr_reader :language, :
|
121
|
+
attr_reader :language, :feature_element_builders
|
99
122
|
|
100
123
|
def initialize(*)
|
101
124
|
super
|
102
125
|
@language = Ast::LanguageDelegator.new(attributes[:language], ::Gherkin::Dialect.for(attributes[:language]))
|
103
|
-
@
|
104
|
-
|
105
|
-
|
126
|
+
@feature_element_builders = attributes[:children].map do |child|
|
127
|
+
case child[:type]
|
128
|
+
when :Background
|
129
|
+
BackgroundBuilder.new(file, child)
|
130
|
+
when :Scenario
|
131
|
+
ScenarioBuilder.new(file, child)
|
132
|
+
else
|
133
|
+
ScenarioOutlineBuilder.new(file, child)
|
134
|
+
end
|
106
135
|
end
|
107
136
|
end
|
108
137
|
|
109
138
|
def result
|
110
|
-
handle_comments(all_comments)
|
111
139
|
Ast::Feature.new(
|
112
140
|
language,
|
113
141
|
location,
|
114
|
-
background,
|
115
142
|
comments,
|
116
143
|
tags,
|
117
144
|
keyword,
|
118
145
|
name,
|
119
146
|
description,
|
120
|
-
|
147
|
+
feature_elements
|
121
148
|
)
|
122
149
|
end
|
123
150
|
|
124
151
|
private
|
125
152
|
|
126
|
-
def
|
127
|
-
|
128
|
-
background_builder.result(language)
|
129
|
-
end
|
130
|
-
|
131
|
-
def scenario_definitions
|
132
|
-
scenario_definition_builders.map { |builder| builder.result(language) }
|
133
|
-
end
|
134
|
-
|
135
|
-
def all_comments
|
136
|
-
attributes[:comments].map do |comment|
|
137
|
-
Ast::Comment.new(
|
138
|
-
Ast::Location.new(file, comment[:location][:line]),
|
139
|
-
comment[:text]
|
140
|
-
)
|
141
|
-
end
|
153
|
+
def feature_elements
|
154
|
+
feature_element_builders.map { |builder| builder.result(language) }
|
142
155
|
end
|
143
156
|
|
144
157
|
def children
|
145
|
-
|
158
|
+
feature_element_builders
|
146
159
|
end
|
147
160
|
end
|
148
161
|
|
@@ -22,10 +22,6 @@ module Cucumber
|
|
22
22
|
scanner = ::Gherkin::TokenScanner.new(document.body)
|
23
23
|
core_builder = AstBuilder.new(document.uri)
|
24
24
|
|
25
|
-
if document.body.strip.empty?
|
26
|
-
return receiver.feature Ast::NullFeature.new
|
27
|
-
end
|
28
|
-
|
29
25
|
begin
|
30
26
|
result = parser.parse(scanner)
|
31
27
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Core
|
3
|
+
module Test
|
4
|
+
module Filters
|
5
|
+
|
6
|
+
# This filter is used for testing Cucumber itself. It adds step definitions
|
7
|
+
# that will activate steps to have passed / failed / pending results
|
8
|
+
# if they use conventional names.
|
9
|
+
#
|
10
|
+
# It was extracted from our test code, and does not have any tests of its own.
|
11
|
+
class ActivateStepsForSelfTest < Core::Filter.new
|
12
|
+
Failure = Class.new(StandardError)
|
13
|
+
|
14
|
+
def test_case(test_case)
|
15
|
+
test_steps = test_case.test_steps.map do |step|
|
16
|
+
case step.name
|
17
|
+
when /fail/
|
18
|
+
step.with_action { raise Failure }
|
19
|
+
when /pending/
|
20
|
+
step.with_action { raise Test::Result::Pending }
|
21
|
+
when /pass/
|
22
|
+
step.with_action {}
|
23
|
+
else
|
24
|
+
step
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
test_case.with_steps(test_steps).describe_to(receiver)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -227,8 +227,12 @@ module Cucumber
|
|
227
227
|
self
|
228
228
|
end
|
229
229
|
|
230
|
-
def total
|
231
|
-
|
230
|
+
def total(for_status = nil)
|
231
|
+
if for_status
|
232
|
+
@totals.fetch(for_status) { 0 }
|
233
|
+
else
|
234
|
+
@totals.reduce(0) { |total, status| total += status[1] }
|
235
|
+
end
|
232
236
|
end
|
233
237
|
|
234
238
|
private
|
@@ -24,8 +24,26 @@ module Cucumber
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def time_in_nanoseconds
|
27
|
-
|
28
|
-
|
27
|
+
MonotonicTime.time_in_nanoseconds
|
28
|
+
end
|
29
|
+
|
30
|
+
module MonotonicTime
|
31
|
+
module_function
|
32
|
+
|
33
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
34
|
+
def time_in_nanoseconds
|
35
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
|
36
|
+
end
|
37
|
+
elsif (defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby') == 'jruby'
|
38
|
+
def time_in_nanoseconds
|
39
|
+
java.lang.System.nanoTime()
|
40
|
+
end
|
41
|
+
else
|
42
|
+
def time_in_nanoseconds
|
43
|
+
t = Time.now
|
44
|
+
t.to_i * 10 ** 9 + t.nsec
|
45
|
+
end
|
46
|
+
end
|
29
47
|
end
|
30
48
|
end
|
31
49
|
end
|
@@ -225,11 +225,7 @@ module Cucumber
|
|
225
225
|
|
226
226
|
context "a Scenario Outline with no Examples" do
|
227
227
|
source do
|
228
|
-
feature
|
229
|
-
scenario_outline do
|
230
|
-
step 'passing <arg>'
|
231
|
-
end
|
232
|
-
end
|
228
|
+
feature(language: 'not-a-language')
|
233
229
|
end
|
234
230
|
it "throws an error" do
|
235
231
|
expect { feature.describe_to(double.as_null_object) }.to raise_error(ParseError)
|
@@ -90,10 +90,7 @@ module Cucumber
|
|
90
90
|
|
91
91
|
context "recording the duration" do
|
92
92
|
before do
|
93
|
-
|
94
|
-
allow( Time ).to receive(:now) { time }
|
95
|
-
allow( time ).to receive(:nsec).and_return(946752000, 946752001)
|
96
|
-
allow( time ).to receive(:to_i).and_return(1377009235, 1377009235)
|
93
|
+
allow( Timer::MonotonicTime ).to receive(:time_in_nanoseconds).and_return(525702744080000, 525702744080001)
|
97
94
|
end
|
98
95
|
|
99
96
|
it "records the nanoseconds duration of the execution on the result" do
|
@@ -253,26 +253,30 @@ module Cucumber::Core::Test
|
|
253
253
|
|
254
254
|
it "counts failed results" do
|
255
255
|
failed.describe_to summary
|
256
|
-
expect( summary.total_failed
|
257
|
-
expect( summary.total
|
256
|
+
expect( summary.total_failed ).to eq 1
|
257
|
+
expect( summary.total(:failed) ).to eq 1
|
258
|
+
expect( summary.total ).to eq 1
|
258
259
|
end
|
259
260
|
|
260
261
|
it "counts passed results" do
|
261
262
|
passed.describe_to summary
|
262
|
-
expect( summary.total_passed
|
263
|
-
expect( summary.total
|
263
|
+
expect( summary.total_passed ).to eq 1
|
264
|
+
expect( summary.total(:passed) ).to eq 1
|
265
|
+
expect( summary.total ).to eq 1
|
264
266
|
end
|
265
267
|
|
266
268
|
it "counts skipped results" do
|
267
269
|
skipped.describe_to summary
|
268
|
-
expect( summary.total_skipped
|
269
|
-
expect( summary.total
|
270
|
+
expect( summary.total_skipped ).to eq 1
|
271
|
+
expect( summary.total(:skipped) ).to eq 1
|
272
|
+
expect( summary.total ).to eq 1
|
270
273
|
end
|
271
274
|
|
272
275
|
it "counts undefined results" do
|
273
276
|
undefined.describe_to summary
|
274
|
-
expect( summary.total_undefined
|
275
|
-
expect( summary.total
|
277
|
+
expect( summary.total_undefined ).to eq 1
|
278
|
+
expect( summary.total(:undefined) ).to eq 1
|
279
|
+
expect( summary.total ).to eq 1
|
276
280
|
end
|
277
281
|
|
278
282
|
it "counts abitrary raisable results" do
|
@@ -283,13 +287,16 @@ module Cucumber::Core::Test
|
|
283
287
|
end
|
284
288
|
|
285
289
|
flickering.new.describe_to summary
|
286
|
-
expect( summary.total_flickering
|
287
|
-
expect( summary.total
|
290
|
+
expect( summary.total_flickering ).to eq 1
|
291
|
+
expect( summary.total(:flickering) ).to eq 1
|
292
|
+
expect( summary.total ).to eq 1
|
288
293
|
end
|
289
294
|
|
290
295
|
it "returns zero for a status where no messges have been received" do
|
291
|
-
expect( summary.total_passed
|
292
|
-
expect( summary.
|
296
|
+
expect( summary.total_passed ).to eq 0
|
297
|
+
expect( summary.total(:passed) ).to eq 0
|
298
|
+
expect( summary.total_ponies ).to eq 0
|
299
|
+
expect( summary.total(:ponies) ).to eq 0
|
293
300
|
end
|
294
301
|
|
295
302
|
it "doesn't count unknown results" do
|
@@ -24,10 +24,7 @@ module Cucumber::Core::Test
|
|
24
24
|
|
25
25
|
context "reporting the duration of a test case" do
|
26
26
|
before do
|
27
|
-
|
28
|
-
allow(Time).to receive(:now).and_return(time)
|
29
|
-
allow(time).to receive(:nsec).and_return(946752000, 946752001)
|
30
|
-
allow(time).to receive(:to_i).and_return(1377009235, 1377009235)
|
27
|
+
allow( Timer::MonotonicTime ).to receive(:time_in_nanoseconds).and_return(525702744080000, 525702744080001)
|
31
28
|
end
|
32
29
|
|
33
30
|
context "for a passing test case" do
|
@@ -6,10 +6,8 @@ module Cucumber
|
|
6
6
|
module Test
|
7
7
|
describe Timer do
|
8
8
|
before do
|
9
|
-
|
10
|
-
|
11
|
-
allow( time ).to receive(:nsec).and_return(946752000, 946752001)
|
12
|
-
allow( time ).to receive(:to_i).and_return(1377009235, 1377009235)
|
9
|
+
allow(Timer::MonotonicTime).to receive(:time_in_nanoseconds)
|
10
|
+
.and_return(525702744080000, 525702744080001)
|
13
11
|
end
|
14
12
|
|
15
13
|
it "returns a Result::Duration object" do
|
data/spec/cucumber/core_spec.rb
CHANGED
@@ -5,6 +5,7 @@ require 'cucumber/core/gherkin/writer'
|
|
5
5
|
require 'cucumber/core/platform'
|
6
6
|
require 'cucumber/core/report/summary'
|
7
7
|
require 'cucumber/core/test/around_hook'
|
8
|
+
require 'cucumber/core/test/filters/activate_steps_for_self_test'
|
8
9
|
|
9
10
|
module Cucumber
|
10
11
|
describe Core do
|
@@ -200,23 +201,6 @@ module Cucumber
|
|
200
201
|
|
201
202
|
describe "executing a test suite" do
|
202
203
|
context "without hooks" do
|
203
|
-
class WithSteps < Core::Filter.new
|
204
|
-
def test_case(test_case)
|
205
|
-
test_steps = test_case.test_steps.map do |step|
|
206
|
-
case step.name
|
207
|
-
when /fail/
|
208
|
-
step.with_action { raise Failure }
|
209
|
-
when /pass/
|
210
|
-
step.with_action {}
|
211
|
-
else
|
212
|
-
step
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
test_case.with_steps(test_steps).describe_to(receiver)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
204
|
it "executes the test cases in the suite" do
|
221
205
|
gherkin = gherkin do
|
222
206
|
feature 'Feature name' do
|
@@ -234,7 +218,7 @@ module Cucumber
|
|
234
218
|
end
|
235
219
|
report = Core::Report::Summary.new
|
236
220
|
|
237
|
-
execute [gherkin], report, [
|
221
|
+
execute [gherkin], report, [Core::Test::Filters::ActivateStepsForSelfTest.new]
|
238
222
|
|
239
223
|
expect( report.test_cases.total ).to eq 2
|
240
224
|
expect( report.test_cases.total_passed ).to eq 1
|
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.
|
4
|
+
version: 1.5.0
|
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: 2016-
|
15
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: gherkin
|
@@ -20,14 +20,14 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: '4.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: '4.0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: bundler
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/cucumber/core/test/around_hook.rb
|
163
163
|
- lib/cucumber/core/test/case.rb
|
164
164
|
- lib/cucumber/core/test/filters.rb
|
165
|
+
- lib/cucumber/core/test/filters/activate_steps_for_self_test.rb
|
165
166
|
- lib/cucumber/core/test/filters/locations_filter.rb
|
166
167
|
- lib/cucumber/core/test/filters/name_filter.rb
|
167
168
|
- lib/cucumber/core/test/filters/tag_filter.rb
|
@@ -219,7 +220,7 @@ rubyforge_project:
|
|
219
220
|
rubygems_version: 2.2.2
|
220
221
|
signing_key:
|
221
222
|
specification_version: 4
|
222
|
-
summary: cucumber-core-1.
|
223
|
+
summary: cucumber-core-1.5.0
|
223
224
|
test_files:
|
224
225
|
- spec/capture_warnings.rb
|
225
226
|
- spec/coverage.rb
|