cucumber-core 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5590978fbb346277b5a34ddc978ff2ba13521bd2
4
- data.tar.gz: dfd394bd74736d25cf4e09eba613d292692fa6b8
3
+ metadata.gz: c1fc45a561bb99340344287c1e671c9cdfe5c3e7
4
+ data.tar.gz: 71d6d270193517dec221d7a61a557abae8bdbeb0
5
5
  SHA512:
6
- metadata.gz: e450582697d48dc63fce47bb733786d45ac3214fbd9eac75399ec7d22ceebe6e1d91d15a86eec542da3c6af6b1ffe194c20b78997a667b0fc5b43073e9ed29b8
7
- data.tar.gz: f454b32d9b6407f474102d9d71073b78c6181679f604f47e0592d5cb4df47970ff8c94af2c2c36291ce24da39fd3b2858ddff55045f43ad97756e32e4500362b
6
+ metadata.gz: 39f345c74c57332f0022faaab37e74cbb6029d544551435a9ab0b2986af82c4c6c33f13554315bf5a01fe5e00760bedbcb131cc9454fceac38025933dd93e07d
7
+ data.tar.gz: 3dfc0894b9e62ecffc08f39b85acc0bfd4ddea7e5bda3ebd11a7fe164011a383e667abee3c0158268b2fcca35607c7c3bb433c338a8ddae731fb63248867ecad
@@ -11,6 +11,7 @@ rvm:
11
11
  branches:
12
12
  only:
13
13
  - master
14
+ - v1.x-bugfix
14
15
 
15
16
  notifications:
16
17
  email:
data/HISTORY.md CHANGED
@@ -1,9 +1,19 @@
1
- ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.4.0...master)
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
@@ -1,4 +1,4 @@
1
- Copyright (C) 2013 The Cucumber Organisation
1
+ Copyright (C) The Cucumber Organisation
2
2
 
3
3
  MIT License (Expat)
4
4
 
data/README.md CHANGED
@@ -126,4 +126,4 @@ undefined ?
126
126
 
127
127
  ## Copyright
128
128
 
129
- Copyright (c) 2013-2014 Cucumber Limited.
129
+ Copyright (c) Cucumber Limited.
@@ -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', '~> 3.2.0'
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, background, comments, tags, keyword, name, description, scenario_definitions)
19
+ def initialize(language, location, comments, tags, keyword, name, description, feature_elements)
20
20
  @language = language
21
21
  @location = location
22
- @background = 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 = scenario_definitions
28
+ @feature_elements = feature_elements
29
29
  end
30
30
 
31
31
  def children
32
- [background] + @feature_elements
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
- FeatureBuilder.new(file, attributes).result
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, :background_builder, :scenario_definition_builders
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
- @background_builder = BackgroundBuilder.new(file, attributes[:background]) if attributes[:background]
104
- @scenario_definition_builders = attributes[:scenario_definitions].map do |sd|
105
- sd[:type] == :Scenario ? ScenarioBuilder.new(file, sd) : ScenarioOutlineBuilder.new(file, sd)
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
- scenario_definitions
147
+ feature_elements
121
148
  )
122
149
  end
123
150
 
124
151
  private
125
152
 
126
- def background
127
- return Ast::EmptyBackground.new unless background_builder
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
- (background_builder ? [background_builder] : []) + scenario_definition_builders
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
- @totals.reduce(0) { |total, status| total += status[1] }
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
- t = Time.now
28
- t.to_i * 10 ** 9 + t.nsec
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
@@ -2,7 +2,7 @@ module Cucumber
2
2
  module Core
3
3
  class Version
4
4
  def self.to_s
5
- "1.4.0"
5
+ "1.5.0"
6
6
  end
7
7
  end
8
8
  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 do
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
- time = double
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 ).to eq 1
257
- expect( summary.total ).to eq 1
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 ).to eq 1
263
- expect( summary.total ).to eq 1
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 ).to eq 1
269
- expect( summary.total ).to eq 1
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 ).to eq 1
275
- expect( summary.total ).to eq 1
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 ).to eq 1
287
- expect( summary.total ).to eq 1
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 ).to eq 0
292
- expect( summary.total_ponies ).to eq 0
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
- time = double
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
- time = double
10
- allow( Time ).to receive(:now) { time }
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
@@ -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, [WithSteps.new]
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.0
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-01-13 00:00:00.000000000 Z
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: 3.2.0
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: 3.2.0
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.4.0
223
+ summary: cucumber-core-1.5.0
223
224
  test_files:
224
225
  - spec/capture_warnings.rb
225
226
  - spec/coverage.rb