cucumber-core 3.0.0.pre.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14ae96e7b157ead29d3bb55f9590dd59abdf2878
4
- data.tar.gz: 72d1ed6b3b96b8d19c92ffa81d6b1be7ae690a7a
3
+ metadata.gz: 15cf4b980313f359f353c814b64882a6e4813284
4
+ data.tar.gz: e43878f811006e883fed0da63d468a8aad348963
5
5
  SHA512:
6
- metadata.gz: da7bd878d405691af0f96191da9e1d32caf7802e7d14ef039c206c524ced53c46305c12e74a8ff8362eef619e54cefa606949424609a1f576a1435cb3754879d
7
- data.tar.gz: b1c03286e6851861e1532547825bc2bd096881acb5140a0cc1717373edbb288620960bf0bb34890459294b020e70bedb0cebd0798a4a3b394a17b0f9e019753d
6
+ metadata.gz: 32015aeac82148a7b00f2f32ae2df457cd63660f1cd8dcbcad8da9bda36dfb3cb8b20bd43312488c19ab3e18074940d90c9ad01826101843e8a1e810930768a1
7
+ data.tar.gz: 8d57d02175e18afc9623bb981a997789561f4ce5a00492e31a9e2a2ad0436a3260210d1342924f7e0c51c2e8056b97f7d0e2d48df456eb8bf11b7dba87d919b7
@@ -9,9 +9,12 @@ matrix:
9
9
  - rvm: 2.2
10
10
  - rvm: 2.1
11
11
  - rvm: 2.0.0
12
- - rvm: jruby-9.1.12.0
12
+ - rvm: jruby-9.1.13.0
13
13
  env:
14
14
  - JRUBY_OPTS="--debug"
15
+ - LC_ALL=en_US.UTF-8
16
+ - LANG=en_US.UTF-8
17
+ - LANGUAGE=en_US.UTF-8
15
18
  allow_failures:
16
19
  - rvm: ruby-head
17
20
  fast_finish: true
@@ -1,9 +1,42 @@
1
- ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/3.0.0.pre.2...master)
1
+ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
2
2
 
3
- ### New Features
4
- ### Bugfixes
5
- ### Removed Features
6
- ### Refactoring
3
+ ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v3.0.0...master) (targetting 3.1.0)
4
+
5
+ ### Changed
6
+
7
+ * N/A
8
+
9
+ ### Added
10
+
11
+ * N/A
12
+
13
+ ### Fixed
14
+
15
+ * N/A
16
+
17
+ ### Improved
18
+
19
+ * N/A
20
+
21
+ ## [3.0.0](https://github.com/cucumber/cucumber-ruby-core/compare/v3.0.0.pre.2...v3.0.0) (2017-09-27)
22
+
23
+ ### Changed
24
+
25
+ * Step#name renamed to #text ([#137](https://github.com/cucumber/cucumber-ruby-core/pull/137) [@olleolleolle](https://github.com/olleolleolle))
26
+ * Use past tense in event names (`xStarting` -> `xStarted`) (see [cucumber/cucumber-ruby#1166](https://github.com/cucumber/cucumber-ruby/issues/1166) @brasmusson).
27
+
28
+ ### Added
29
+
30
+ * Do not create test cases for scenarios with no steps ([#144](https://github.com/cucumber/cucumber-ruby-core/pull/144) @brasmusson)
31
+ * Handle selective strict settings ([#143](https://github.com/cucumber/cucumber-ruby-core/pull/143) @brasmusson)
32
+
33
+ ### Fixed
34
+
35
+ * Fix DataTable's Location to be aware of all of its lines ([#142](https://github.com/cucumber/cucumber-ruby-core/pull/142) @botandrose)
36
+
37
+ ### Improved
38
+
39
+ * As per [#251](https://github.com/cucumber/cucumber/issues/251): renamed History.md to CHANGELOG.md, added contributing message at beginning, and misc formatting. ([#145](https://github.com/cucumber/cucumber-ruby-core/pull/145) [jaysonesmith](https://github.com/jaysonesmith))
7
40
 
8
41
  ## [3.0.0.pre.2](https://github.com/cucumber/cucumber-ruby-core/compare/v2.0.0...3.0.0.pre.2) (2017-07-26)
9
42
 
@@ -2,9 +2,8 @@ Release Process
2
2
  ===============
3
3
 
4
4
  * Bump the version number in `lib/cucumber/core/version.rb`
5
- * Update `HISTORY.md` is updated with the upcoming version number and entries
6
- for all changes recorded.
7
- * Now release it
5
+ * Update `CHANGELOG.md` with the upcoming version number and create a new `In Git` section
6
+ * Now release it:
8
7
 
9
8
  ```
10
9
  bundle update
data/README.md CHANGED
@@ -75,7 +75,7 @@ class ActivateSteps < Cucumber::Core::Filter.new
75
75
  private
76
76
 
77
77
  def activate(step)
78
- case step.name
78
+ case step.text
79
79
  when /fail/
80
80
  step.with_action { raise Failure }
81
81
  when /pass/
@@ -105,7 +105,7 @@ end
105
105
  MyRunner.new.execute([feature], [ActivateSteps.new]) do |events|
106
106
  events.on(:test_step_finished) do |event|
107
107
  test_step, result = event.test_step, event.result
108
- puts "#{test_step.name} #{result}"
108
+ puts "#{test_step.text} #{result}"
109
109
  end
110
110
  end
111
111
  ```
@@ -23,10 +23,6 @@ module Cucumber
23
23
  []
24
24
  end
25
25
 
26
- def to_sexp
27
- []
28
- end
29
-
30
26
  def inspect
31
27
  "#<#{self.class}>"
32
28
  end
@@ -42,16 +42,6 @@ module Cucumber
42
42
  end
43
43
  end
44
44
 
45
- def to_sexp
46
- sexp = [:feature, file, name]
47
- comment = @comment.to_sexp
48
- sexp += [comment] if comment
49
- tags = @tags.to_sexp
50
- sexp += tags if tags.any?
51
- sexp += @feature_elements.map{|fe| fe.to_sexp}
52
- sexp
53
- end
54
-
55
45
  private
56
46
 
57
47
  def description_for_visitors
@@ -11,19 +11,23 @@ module Cucumber
11
11
  include HasLocation
12
12
  include DescribesItself
13
13
 
14
- attr_reader :language, :location, :comments, :keyword, :name, :multiline_arg
14
+ attr_reader :language, :location, :comments, :keyword, :text, :multiline_arg
15
15
 
16
16
  def initialize(language, location, comments, keyword, text, multiline_arg)
17
- @language, @location, @comments, @keyword, @name, @multiline_arg = language, location, comments, keyword, text, multiline_arg
17
+ @language, @location, @comments, @keyword, @text, @multiline_arg = language, location, comments, keyword, text, multiline_arg
18
18
  end
19
19
 
20
20
  def to_step(row)
21
- Ast::ExpandedOutlineStep.new(self, language, row.location, comments, keyword, row.expand(name), replace_multiline_arg(row))
21
+ Ast::ExpandedOutlineStep.new(self, language, row.location, comments, keyword, row.expand(text), replace_multiline_arg(row))
22
+ end
23
+
24
+ def to_s
25
+ text
22
26
  end
23
27
 
24
28
  def inspect
25
- keyword_and_name = [keyword, name].join(": ")
26
- %{#<#{self.class} "#{keyword_and_name}" (#{location})>}
29
+ keyword_and_text = [keyword, text].join(": ")
30
+ %{#<#{self.class} "#{keyword_and_text}" (#{location})>}
27
31
  end
28
32
 
29
33
  private
@@ -47,4 +51,3 @@ module Cucumber
47
51
  end
48
52
  end
49
53
  end
50
-
@@ -31,16 +31,6 @@ module Cucumber
31
31
  raw_steps
32
32
  end
33
33
 
34
- def to_sexp
35
- sexp = [:scenario, line, keyword, name]
36
- comment = comment.to_sexp
37
- sexp += [comment] if comment
38
- tags = tags.to_sexp
39
- sexp += tags if tags.any?
40
- sexp += step_invocations.to_sexp if step_invocations.any?
41
- sexp
42
- end
43
-
44
34
  private
45
35
 
46
36
  def description_for_visitors
@@ -9,18 +9,18 @@ module Cucumber
9
9
  include HasLocation
10
10
  include DescribesItself
11
11
 
12
- attr_reader :keyword, :name, :language, :comments, :exception, :multiline_arg
12
+ attr_reader :keyword, :text, :language, :comments, :exception, :multiline_arg
13
13
 
14
- def initialize(language, location, comments, keyword, name, multiline_arg)
15
- @language, @location, @comments, @keyword, @name, @multiline_arg = language, location, comments, keyword, name, multiline_arg
14
+ def initialize(language, location, comments, keyword, text, multiline_arg)
15
+ @language, @location, @comments, @keyword, @text, @multiline_arg = language, location, comments, keyword, text, multiline_arg
16
16
  end
17
17
 
18
- def to_sexp
19
- [:step, line, keyword, name, @multiline_arg.to_sexp]
18
+ def to_s
19
+ text
20
20
  end
21
21
 
22
22
  def backtrace_line
23
- "#{location}:in `#{keyword}#{name}'"
23
+ "#{location}:in `#{keyword}#{text}'"
24
24
  end
25
25
 
26
26
  def actual_keyword(previous_step_keyword = nil)
@@ -36,8 +36,8 @@ module Cucumber
36
36
  end
37
37
 
38
38
  def inspect
39
- keyword_and_name = [keyword, name].join(": ")
40
- %{#<#{self.class} "#{keyword_and_name}" (#{location})>}
39
+ keyword_and_text = [keyword, text].join(": ")
40
+ %{#<#{self.class} "#{keyword_and_text}" (#{location})>}
41
41
  end
42
42
 
43
43
  private
@@ -53,8 +53,8 @@ module Cucumber
53
53
 
54
54
  class ExpandedOutlineStep < Step
55
55
 
56
- def initialize(outline_step, language, location, comments, keyword, name, multiline_arg)
57
- @outline_step, @language, @location, @comments, @keyword, @name, @multiline_arg = outline_step, language, location, comments, keyword, name, multiline_arg
56
+ def initialize(outline_step, language, location, comments, keyword, text, multiline_arg)
57
+ @outline_step, @language, @location, @comments, @keyword, @text, @multiline_arg = outline_step, language, location, comments, keyword, text, multiline_arg
58
58
  end
59
59
 
60
60
  def all_locations
@@ -65,7 +65,7 @@ module Cucumber
65
65
 
66
66
  def backtrace_line
67
67
  "#{step_backtrace_line}\n" +
68
- "#{@outline_step.location}:in `#{@outline_step.keyword}#{@outline_step.name}'"
68
+ "#{@outline_step.location}:in `#{@outline_step.keyword}#{@outline_step.text}'"
69
69
  end
70
70
 
71
71
  end
@@ -45,7 +45,7 @@ module Cucumber
45
45
  end
46
46
 
47
47
  def on_test_case(source)
48
- Test::Case.new(test_steps, source).describe_to(receiver)
48
+ Test::Case.new(test_steps, source).describe_to(receiver) if test_steps.count > 0
49
49
  @test_steps = nil
50
50
  self
51
51
  end
@@ -5,7 +5,7 @@ module Cucumber
5
5
  module Events
6
6
 
7
7
  # Signals that a {Test::Case} is about to be executed
8
- class TestCaseStarting < Event.new(:test_case)
8
+ class TestCaseStarted < Event.new(:test_case)
9
9
 
10
10
  # @return [Test::Case] the test case to be executed
11
11
  attr_reader :test_case
@@ -13,7 +13,7 @@ module Cucumber
13
13
  end
14
14
 
15
15
  # Signals that a {Test::Step} is about to be executed
16
- class TestStepStarting < Event.new(:test_step)
16
+ class TestStepStarted < Event.new(:test_step)
17
17
 
18
18
  # @return [Test::Step] the test step to be executed
19
19
  attr_reader :test_step
@@ -47,8 +47,8 @@ module Cucumber
47
47
  # that will be used by the {EventBus} by default.
48
48
  def self.registry
49
49
  build_registry(
50
- TestCaseStarting,
51
- TestStepStarting,
50
+ TestCaseStarted,
51
+ TestStepStarted,
52
52
  TestStepFinished,
53
53
  TestCaseFinished,
54
54
  )
@@ -373,6 +373,12 @@ module Cucumber
373
373
  def rows
374
374
  attributes[:rows] = attributes[:rows].map { |r| r[:cells].map { |c| c[:value] } }
375
375
  end
376
+
377
+ def location
378
+ first_line = attributes[:location][:line]
379
+ last_line = first_line + attributes[:rows].length - 1
380
+ Ast::Location.new(file, first_line..last_line)
381
+ end
376
382
  end
377
383
 
378
384
  class DocStringBuilder < Builder
@@ -12,7 +12,7 @@ module Cucumber
12
12
  subscribe_to(event_bus)
13
13
  end
14
14
 
15
- def ok?(be_strict = false)
15
+ def ok?(be_strict = Test::Result::StrictConfiguration.new)
16
16
  test_cases.ok?(be_strict)
17
17
  end
18
18
 
@@ -13,7 +13,7 @@ module Cucumber
13
13
 
14
14
  def test_case(test_case)
15
15
  test_steps = test_case.test_steps.map do |step|
16
- case step.name
16
+ case step.text
17
17
  when /fail/
18
18
  step.with_action { raise Failure }
19
19
  when /pending/
@@ -6,11 +6,12 @@ module Cucumber
6
6
  module Test
7
7
  module Result
8
8
  TYPES = [:failed, :flaky, :skipped, :undefined, :pending, :passed, :unknown].freeze
9
+ STRICT_AFFECTED_TYPES = [:flaky, :undefined, :pending].freeze
9
10
 
10
- def self.ok?(type, be_strict = false)
11
+ def self.ok?(type, be_strict = StrictConfiguration.new)
11
12
  private
12
13
  class_name = type.to_s.slice(0, 1).capitalize + type.to_s.slice(1..-1)
13
- const_get(class_name).ok?(be_strict)
14
+ const_get(class_name).ok?(be_strict.strict?(type))
14
15
  end
15
16
 
16
17
  # Defines to_sym on a result class for the given result type
@@ -67,8 +68,8 @@ module Cucumber
67
68
  "✓"
68
69
  end
69
70
 
70
- def ok?(be_strict = false)
71
- self.class.ok?(be_strict)
71
+ def ok?(be_strict = nil)
72
+ self.class.ok?
72
73
  end
73
74
 
74
75
  def with_appended_backtrace(step)
@@ -106,8 +107,8 @@ module Cucumber
106
107
  "✗"
107
108
  end
108
109
 
109
- def ok?(be_strict = false)
110
- self.class.ok?(be_strict)
110
+ def ok?(be_strict = nil)
111
+ self.class.ok?
111
112
  end
112
113
 
113
114
  def with_duration(new_duration)
@@ -164,8 +165,8 @@ module Cucumber
164
165
  filter.new(dup).exception
165
166
  end
166
167
 
167
- def ok?(be_strict = false)
168
- self.class.ok?(be_strict)
168
+ def ok?(be_strict = StrictConfiguration.new)
169
+ self.class.ok?(be_strict.strict?(to_sym))
169
170
  end
170
171
  end
171
172
 
@@ -223,6 +224,54 @@ module Cucumber
223
224
  end
224
225
  end
225
226
 
227
+ # Handles the strict settings for the result types that are
228
+ # affected by the strict options (that is the STRICT_AFFECTED_TYPES).
229
+ class StrictConfiguration
230
+ attr_accessor :settings
231
+ private :settings
232
+
233
+ def initialize(strict_types = [])
234
+ @settings = Hash[STRICT_AFFECTED_TYPES.map { |t| [t, :default] }]
235
+ strict_types.each do |type|
236
+ set_strict(true, type)
237
+ end
238
+ end
239
+
240
+ def strict?(type = nil)
241
+ if type.nil?
242
+ settings.each do |_key, value|
243
+ return true if value == true
244
+ end
245
+ false
246
+ else
247
+ return false unless settings.key?(type)
248
+ return false unless set?(type)
249
+ settings[type]
250
+ end
251
+ end
252
+
253
+ def set_strict(setting, type = nil)
254
+ if type.nil?
255
+ STRICT_AFFECTED_TYPES.each do |t|
256
+ set_strict(setting, t)
257
+ end
258
+ else
259
+ settings[type] = setting
260
+ end
261
+ end
262
+
263
+ def merge!(other)
264
+ settings.keys.each do |type|
265
+ set_strict(other.strict?(type), type) if other.set?(type)
266
+ end
267
+ self
268
+ end
269
+
270
+ def set?(type)
271
+ settings[type] != :default
272
+ end
273
+ end
274
+
226
275
  #
227
276
  # An object that responds to the description protocol from the results
228
277
  # and collects summary information.
@@ -250,7 +299,7 @@ module Cucumber
250
299
  end
251
300
  end
252
301
 
253
- def ok?(be_strict = false)
302
+ def ok?(be_strict = StrictConfiguration.new)
254
303
  TYPES.each do |type|
255
304
  if get_total(type) > 0
256
305
  return false unless Result.ok?(type, be_strict)
@@ -15,7 +15,7 @@ module Cucumber
15
15
  def test_case(test_case, &descend)
16
16
  @running_test_case = RunningTestCase.new
17
17
  @running_test_step = nil
18
- event_bus.test_case_starting(test_case)
18
+ event_bus.test_case_started(test_case)
19
19
  descend.call(self)
20
20
  event_bus.test_case_finished(test_case, running_test_case.result)
21
21
  self
@@ -23,7 +23,7 @@ module Cucumber
23
23
 
24
24
  def test_step(test_step)
25
25
  @running_test_step = test_step
26
- event_bus.test_step_starting test_step
26
+ event_bus.test_step_started test_step
27
27
  step_result = running_test_case.execute(test_step)
28
28
  event_bus.test_step_finished test_step, step_result
29
29
  @running_test_step = nil
@@ -102,7 +102,7 @@ module Cucumber
102
102
 
103
103
  def execute(test_step, monitor, &continue)
104
104
  result = test_step.execute(monitor.result, &continue)
105
- result = result.with_message(%(Undefined step: "#{test_step.name}")) if result.undefined?
105
+ result = result.with_message(%(Undefined step: "#{test_step.text}")) if result.undefined?
106
106
  result = result.with_appended_backtrace(test_step.source.last) if IsStepVisitor.new(test_step).step?
107
107
  result.describe_to(monitor, result)
108
108
  end
@@ -36,8 +36,12 @@ module Cucumber
36
36
  self.class.new(source, Test::Action.new(location, &block))
37
37
  end
38
38
 
39
- def name
40
- source.last.name
39
+ def text
40
+ source.last.text
41
+ end
42
+
43
+ def to_s
44
+ text
41
45
  end
42
46
 
43
47
  def location
@@ -3,7 +3,7 @@ module Cucumber
3
3
  module Core
4
4
  class Version
5
5
  def self.to_s
6
- "3.0.0.pre.2"
6
+ "3.0.0"
7
7
  end
8
8
  end
9
9
  end
@@ -9,12 +9,12 @@ module Cucumber
9
9
  module Core
10
10
  module Ast
11
11
  describe OutlineStep do
12
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, name, multiline_arg) }
12
+ let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, multiline_arg) }
13
13
  let(:language) { double }
14
14
  let(:location) { double }
15
15
  let(:comments) { double }
16
16
  let(:keyword) { double }
17
- let(:name) { 'anything' }
17
+ let(:text) { 'anything' }
18
18
  let(:multiline_arg) { EmptyMultilineArgument.new }
19
19
 
20
20
  describe 'location' do
@@ -28,6 +28,12 @@ module Cucumber
28
28
  end
29
29
  end
30
30
 
31
+ describe "to_s" do
32
+ it "returns the text of the step" do
33
+ expect(outline_step.to_s).to eq 'anything'
34
+ end
35
+ end
36
+
31
37
  describe 'comments' do
32
38
  it "has comments" do
33
39
  expect( outline_step ).to respond_to(:comments)
@@ -36,18 +42,18 @@ module Cucumber
36
42
 
37
43
  describe "converting to a Step" do
38
44
  context "a single argument in the name" do
39
- let(:name) { 'a <color> cucumber' }
45
+ let(:text) { 'a <color> cucumber' }
40
46
 
41
47
  it "replaces the argument" do
42
48
  row = ExamplesTable::Row.new({'color' => 'green'}, 1, location, language, comments)
43
- expect( outline_step.to_step(row).name ).to eq 'a green cucumber'
49
+ expect( outline_step.to_step(row).text ).to eq 'a green cucumber'
44
50
  end
45
51
 
46
52
  end
47
53
 
48
54
  context "when the step has a DataTable" do
49
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, name, table) }
50
- let(:name) { "anything" }
55
+ let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, table) }
56
+ let(:text) { "anything" }
51
57
  let(:table) { DataTable.new([['x', 'y'],['a', 'a <arg>']], Location.new('foo.feature', 23)) }
52
58
 
53
59
  it "replaces the arguments in the DataTable" do
@@ -64,9 +70,9 @@ module Cucumber
64
70
 
65
71
  context "when the step has a DocString" do
66
72
  let(:location) { double }
67
- let(:outline_step) { OutlineStep.new(language, location, comments, keyword, name, doc_string) }
73
+ let(:outline_step) { OutlineStep.new(language, location, comments, keyword, text, doc_string) }
68
74
  let(:doc_string) { DocString.new('a <arg> that needs replacing', '', location) }
69
- let(:name) { 'anything' }
75
+ let(:text) { 'anything' }
70
76
 
71
77
  it "replaces the arguments in the DocString" do
72
78
  visitor = double
@@ -9,9 +9,17 @@ module Cucumber
9
9
  module Ast
10
10
  describe Step do
11
11
  let(:step) do
12
- language, location, comments, keyword, name = *double
12
+ text = "a passing step"
13
+ keyword = "Given"
14
+ language, location, comments = *double
13
15
  multiline_arg = EmptyMultilineArgument.new
14
- Step.new(language, location, comments, keyword, name, multiline_arg)
16
+ Step.new(language, location, comments, keyword, text, multiline_arg)
17
+ end
18
+
19
+ describe "to_s" do
20
+ it("returns the text of the step") do
21
+ expect(step.to_s).to eq("a passing step")
22
+ end
15
23
  end
16
24
 
17
25
  describe "describing itself" do
@@ -109,10 +117,10 @@ module Cucumber
109
117
  describe ExpandedOutlineStep do
110
118
  let(:outline_step) { double }
111
119
  let(:step) do
112
- language, location, keyword, name = *double
120
+ language, location, keyword, text = *double
113
121
  multiline_arg = EmptyMultilineArgument.new
114
122
  comments = []
115
- ExpandedOutlineStep.new(outline_step, language, location, comments, keyword, name, multiline_arg)
123
+ ExpandedOutlineStep.new(outline_step, language, location, comments, keyword, text, multiline_arg)
116
124
  end
117
125
 
118
126
  describe "describing itself" do
@@ -139,7 +139,7 @@ module Cucumber::Core
139
139
  expect( visitor ).to receive(:test_step) do |test_step|
140
140
  visit_source(test_step) do |source_visitor|
141
141
  expect( source_visitor ).to receive(:step) do |step|
142
- expect(step.name).to eq 'passing 1 with 2'
142
+ expect(step.text).to eq 'passing 1 with 2'
143
143
  end
144
144
  end
145
145
  end.once.ordered
@@ -147,7 +147,7 @@ module Cucumber::Core
147
147
  expect( visitor ).to receive(:test_step) do |test_step|
148
148
  visit_source(test_step) do |source_visitor|
149
149
  expect( source_visitor ).to receive(:step) do |step|
150
- expect(step.name).to eq 'as well as 3'
150
+ expect(step.text).to eq 'as well as 3'
151
151
  end
152
152
  end
153
153
  end.once.ordered
@@ -157,6 +157,23 @@ module Cucumber::Core
157
157
  end
158
158
  end
159
159
 
160
+ context 'empty scenarios' do
161
+ it 'does not create test cases for them' do
162
+ gherkin_documents = [
163
+ gherkin do
164
+ feature do
165
+ scenario do
166
+ end
167
+ end
168
+ end
169
+ ]
170
+ compile(gherkin_documents) do |visitor|
171
+ expect( visitor ).to receive(:test_case).never
172
+ expect( visitor ).to receive(:done).once.ordered
173
+ end
174
+ end
175
+ end
176
+
160
177
  describe Compiler::FeatureCompiler do
161
178
  let(:receiver) { double('receiver') }
162
179
  let(:compiler) { Compiler::FeatureCompiler.new(receiver) }
@@ -30,7 +30,7 @@ module Cucumber::Core
30
30
  my_filter = my_filter_class.new
31
31
  expect(receiver).to receive(:test_case) { |test_case|
32
32
  expect(test_case.test_steps.length).to eq 1
33
- expect(test_case.test_steps.first.name).to eq 'a step'
33
+ expect(test_case.test_steps.first.text).to eq 'a step'
34
34
  }.exactly(2).times
35
35
  compile [doc], receiver, [my_filter]
36
36
  end
@@ -197,7 +197,7 @@ module Cucumber
197
197
  allow( visitor ).to receive(:scenario_outline).and_yield(visitor)
198
198
  allow( visitor ).to receive(:examples_table)
199
199
  expect( visitor ).to receive(:outline_step) do |step|
200
- expect( step.name ).to eq 'passing <arg>'
200
+ expect( step.text ).to eq 'passing <arg>'
201
201
  end
202
202
  feature.describe_to(visitor)
203
203
  end
@@ -159,14 +159,16 @@ module Cucumber::Core::Report
159
159
  event_bus.send(:test_case_finished, test_case, pending_result)
160
160
 
161
161
  expect( @summary.ok? ).to eq true
162
- expect( @summary.ok?(true) ).to eq false
162
+ be_strict = ::Cucumber::Core::Test::Result::StrictConfiguration.new([:pending])
163
+ expect( @summary.ok?(be_strict) ).to eq false
163
164
  end
164
165
 
165
166
  it "undefined test case is ok if not strict" do
166
167
  event_bus.send(:test_case_finished, test_case, undefined_result)
167
168
 
168
169
  expect( @summary.ok? ).to eq true
169
- expect( @summary.ok?(true) ).to eq false
170
+ be_strict = ::Cucumber::Core::Test::Result::StrictConfiguration.new([:undefined])
171
+ expect( @summary.ok?(be_strict) ).to eq false
170
172
  end
171
173
  end
172
174
  end
@@ -277,7 +277,7 @@ module Cucumber
277
277
  gherkin = Gherkin::Document.new('features/treasure.feature', %{# language: en-pirate
278
278
  Ahoy matey!: Treasure map
279
279
  Heave to: Find the treasure
280
- Gangway!: a map
280
+ Gangway! a map
281
281
  })
282
282
  receiver = double.as_null_object
283
283
  expect( receiver ).to receive(:test_case) do |test_case|
@@ -96,8 +96,8 @@ module Cucumber::Core
96
96
  Given a table
97
97
  | a | b |
98
98
  | 1 | 2 |
99
+ | 3 | 4 |
99
100
 
100
- Scenario: empty
101
101
  END
102
102
  end
103
103
 
@@ -112,13 +112,6 @@ module Cucumber::Core
112
112
  expect(receiver.test_case_locations).to eq [test_case_named('two').location]
113
113
  end
114
114
 
115
- it 'matches the precise location of an empty scenario' do
116
- location = test_case_named('empty').location
117
- filter = Test::LocationsFilter.new([location])
118
- compile [doc], receiver, [filter]
119
- expect(receiver.test_case_locations).to eq [test_case_named('empty').location]
120
- end
121
-
122
115
  it 'matches multiple locations' do
123
116
  good_location = Ast::Location.new(file, 8)
124
117
  bad_location = Ast::Location.new(file, 5)
@@ -201,10 +194,25 @@ module Cucumber::Core
201
194
  test_cases.find { |c| c.name == 'with a table' }
202
195
  end
203
196
 
204
- it "matches a location on the first table row" do
197
+ it "matches a location at the start of the table" do
205
198
  location = Ast::Location.new(file, 23)
206
199
  expect( test_case.match_locations?([location]) ).to be_truthy
207
200
  end
201
+
202
+ it "matches a location in the middle of the table" do
203
+ location = Ast::Location.new(file, 24)
204
+ expect( test_case.match_locations?([location]) ).to be_truthy
205
+ end
206
+
207
+ it "matches a location at the end of the table" do
208
+ location = Ast::Location.new(file, 25)
209
+ expect( test_case.match_locations?([location]) ).to be_truthy
210
+ end
211
+
212
+ it "does not match a location after the table" do
213
+ location = Ast::Location.new(file, 26)
214
+ expect( test_case.match_locations?([location]) ).to be_falsey
215
+ end
208
216
  end
209
217
 
210
218
  context "with duplicate locations in the filter" do
@@ -49,8 +49,7 @@ module Cucumber::Core::Test
49
49
  specify { expect( result ).not_to be_flaky }
50
50
 
51
51
  specify { expect( result ).to be_ok }
52
- specify { expect( result.ok?(false) ).to be_truthy }
53
- specify { expect( result.ok?(true) ).to be_truthy }
52
+ specify { expect( result.ok? ).to be_truthy }
54
53
  end
55
54
 
56
55
  describe Result::Failed do
@@ -109,8 +108,7 @@ module Cucumber::Core::Test
109
108
  specify { expect( result ).not_to be_flaky }
110
109
 
111
110
  specify { expect( result ).to_not be_ok }
112
- specify { expect( result.ok?(false) ).to be_falsey }
113
- specify { expect( result.ok?(true) ).to be_falsey }
111
+ specify { expect( result.ok? ).to be_falsey }
114
112
  end
115
113
 
116
114
  describe Result::Unknown do
@@ -202,8 +200,9 @@ module Cucumber::Core::Test
202
200
  specify { expect( result ).not_to be_flaky }
203
201
 
204
202
  specify { expect( result ).to be_ok }
205
- specify { expect( result.ok?(false) ).to be_truthy }
206
- specify { expect( result.ok?(true) ).to be_falsey }
203
+ specify { expect( result.ok? ).to be_truthy }
204
+ be_strict = Result::StrictConfiguration.new([:undefined])
205
+ specify { expect( result.ok?(be_strict) ).to be_falsey }
207
206
  end
208
207
 
209
208
  describe Result::Skipped do
@@ -225,8 +224,7 @@ module Cucumber::Core::Test
225
224
  specify { expect( result ).not_to be_flaky }
226
225
 
227
226
  specify { expect( result ).to be_ok }
228
- specify { expect( result.ok?(false) ).to be_truthy }
229
- specify { expect( result.ok?(true) ).to be_truthy }
227
+ specify { expect( result.ok? ).to be_truthy }
230
228
  end
231
229
 
232
230
  describe Result::Pending do
@@ -249,8 +247,9 @@ module Cucumber::Core::Test
249
247
  specify { expect( result ).to be_pending }
250
248
 
251
249
  specify { expect( result ).to be_ok }
252
- specify { expect( result.ok?(false) ).to be_truthy }
253
- specify { expect( result.ok?(true) ).to be_falsey }
250
+ specify { expect( result.ok? ).to be_truthy }
251
+ be_strict = Result::StrictConfiguration.new([:pending])
252
+ specify { expect( result.ok?(be_strict) ).to be_falsey }
254
253
  end
255
254
 
256
255
  describe Result::Flaky do
@@ -258,6 +257,77 @@ module Cucumber::Core::Test
258
257
  specify { expect( Result::Flaky.ok?(true) ).to be_falsey }
259
258
  end
260
259
 
260
+ describe Result::StrictConfiguration do
261
+ subject(:strict_configuration) { Result::StrictConfiguration.new}
262
+
263
+ describe '#set_strict' do
264
+ context 'no type argument' do
265
+ it 'sets all result types to the setting argument' do
266
+ strict_configuration.set_strict(true)
267
+ expect( strict_configuration.strict?(:undefined) ).to be_truthy
268
+ expect( strict_configuration.strict?(:pending) ).to be_truthy
269
+ expect( strict_configuration.strict?(:flaky) ).to be_truthy
270
+
271
+ strict_configuration.set_strict(false)
272
+ expect( strict_configuration.strict?(:undefined) ).to be_falsey
273
+ expect( strict_configuration.strict?(:pending) ).to be_falsey
274
+ expect( strict_configuration.strict?(:flaky) ).to be_falsey
275
+ end
276
+ end
277
+ context 'with type argument' do
278
+ it 'sets the specified result type to the setting argument' do
279
+ strict_configuration.set_strict(true, :undefined)
280
+ expect( strict_configuration.strict?(:undefined) ).to be_truthy
281
+ expect( strict_configuration.set?(:pending) ).to be_falsey
282
+ expect( strict_configuration.set?(:flaky) ).to be_falsey
283
+
284
+ strict_configuration.set_strict(false, :undefined)
285
+ expect( strict_configuration.strict?(:undefined) ).to be_falsey
286
+ expect( strict_configuration.set?(:pending) ).to be_falsey
287
+ expect( strict_configuration.set?(:flaky) ).to be_falsey
288
+ end
289
+ end
290
+ end
291
+
292
+ describe '#strict?' do
293
+ context 'no type argument' do
294
+ it 'returns true if any result type is set to strict' do
295
+ strict_configuration.set_strict(false, :pending)
296
+ expect( strict_configuration.strict? ).to be_falsey
297
+
298
+ strict_configuration.set_strict(true, :flaky)
299
+ expect( strict_configuration.strict? ).to be_truthy
300
+ end
301
+ end
302
+ context 'with type argument' do
303
+ it 'returns true if the specified result type is set to strict' do
304
+ strict_configuration.set_strict(false, :pending)
305
+ strict_configuration.set_strict(true, :flaky)
306
+
307
+ expect( strict_configuration.strict?(:undefined) ).to be_falsey
308
+ expect( strict_configuration.strict?(:pending) ).to be_falsey
309
+ expect( strict_configuration.strict?(:flaky) ).to be_truthy
310
+ end
311
+ end
312
+ end
313
+
314
+ describe '#merge!' do
315
+ let(:merged_configuration) { Result::StrictConfiguration.new }
316
+ it 'sets the not default values from the argument accordingly' do
317
+ strict_configuration.set_strict(false, :undefined)
318
+ strict_configuration.set_strict(false, :pending)
319
+ strict_configuration.set_strict(true, :flaky)
320
+ merged_configuration.set_strict(true, :pending)
321
+ merged_configuration.set_strict(false, :flaky)
322
+ strict_configuration.merge!(merged_configuration)
323
+
324
+ expect( strict_configuration.strict?(:undefined) ).to be_falsey
325
+ expect( strict_configuration.strict?(:pending) ).to be_truthy
326
+ expect( strict_configuration.strict?(:flaky) ).to be_falsey
327
+ end
328
+ end
329
+ end
330
+
261
331
  describe Result::Summary do
262
332
  let(:summary) { Result::Summary.new }
263
333
  let(:failed) { Result::Failed.new(Result::Duration.new(10), exception) }
@@ -360,19 +430,22 @@ module Cucumber::Core::Test
360
430
  it "pending result is ok if not strict" do
361
431
  pending.describe_to summary
362
432
  expect( summary.ok? ).to be true
363
- expect( summary.ok?(true) ).to be false
433
+ be_strict = Result::StrictConfiguration.new([:pending])
434
+ expect( summary.ok?(be_strict) ).to be false
364
435
  end
365
436
 
366
437
  it "undefined result is ok if not strict" do
367
438
  undefined.describe_to summary
368
439
  expect( summary.ok? ).to be true
369
- expect( summary.ok?(true) ).to be false
440
+ be_strict = Result::StrictConfiguration.new([:undefined])
441
+ expect( summary.ok?(be_strict) ).to be false
370
442
  end
371
443
 
372
444
  it "flaky result is ok if not strict" do
373
445
  summary.flaky
374
446
  expect( summary.ok? ).to be true
375
- expect( summary.ok?(true) ).to be false
447
+ be_strict = Result::StrictConfiguration.new([:flaky])
448
+ expect( summary.ok?(be_strict) ).to be false
376
449
  end
377
450
  end
378
451
  end
@@ -19,7 +19,7 @@ module Cucumber::Core::Test
19
19
  let(:exception) { StandardError.new('test error') }
20
20
 
21
21
  before do
22
- allow(event_bus).to receive(:test_case_starting)
22
+ allow(event_bus).to receive(:test_case_started)
23
23
  allow(source).to receive(:location)
24
24
  end
25
25
 
@@ -66,8 +66,8 @@ module Cucumber::Core::Test
66
66
  context "without steps" do
67
67
  let(:test_steps) { [] }
68
68
 
69
- it "emits a test_case_starting event before running the test case" do
70
- expect(event_bus).to receive(:test_case_starting).with(test_case)
69
+ it "emits a test_case_started event before running the test case" do
70
+ expect(event_bus).to receive(:test_case_started).with(test_case)
71
71
  test_case.describe_to runner
72
72
  end
73
73
 
@@ -99,7 +99,7 @@ module Cucumber::Core::Test
99
99
  expect(event_bus).to receive(:test_case_finished) do |test_case, result|
100
100
  expect( result ).to be_undefined
101
101
  end
102
- allow( undefined.source.last ).to receive(:name)
102
+ allow( undefined.source.last ).to receive(:text)
103
103
  test_case.describe_to runner
104
104
  end
105
105
 
@@ -107,7 +107,7 @@ module Cucumber::Core::Test
107
107
  expect(event_bus).to receive(:test_case_finished) do |test_case, result|
108
108
  expect( result.message ).to eq("Undefined step: \"step name\"")
109
109
  end
110
- expect( undefined.source.last ).to receive(:name).and_return("step name")
110
+ expect( undefined.source.last ).to receive(:text).and_return("step name")
111
111
  test_case.describe_to runner
112
112
  end
113
113
 
@@ -116,7 +116,7 @@ module Cucumber::Core::Test
116
116
  expect( result.backtrace ).to eq(["step line"])
117
117
  end
118
118
  expect( undefined.source.last ).to receive(:backtrace_line).and_return("step line")
119
- allow( undefined.source.last ).to receive(:name)
119
+ allow( undefined.source.last ).to receive(:text)
120
120
  test_case.describe_to runner
121
121
  end
122
122
  end
@@ -73,11 +73,11 @@ module Cucumber::Core::Test
73
73
  end
74
74
  end
75
75
 
76
- it "exposes the name and location of the AST step or hook as attributes" do
77
- name, location = double, double
78
- step_or_hook = double(name: name, location: location)
76
+ it "exposes the text and location of the AST step or hook as attributes" do
77
+ text, location = double, double
78
+ step_or_hook = double(text: text, location: location)
79
79
  test_step = Step.new([step_or_hook])
80
- expect( test_step.name ).to eq name
80
+ expect( test_step.text ).to eq text
81
81
  expect( test_step.location ).to eq location
82
82
  end
83
83
 
@@ -88,5 +88,11 @@ module Cucumber::Core::Test
88
88
  expect( test_step.action_location ).to eq location
89
89
  end
90
90
 
91
+ it "returns the text of the AST step when converted to a string" do
92
+ ast_step = double(text: 'a passing step', location: double)
93
+ test_step = Step.new([ast_step])
94
+ expect( test_step.to_s ).to eq 'a passing step'
95
+ end
96
+
91
97
  end
92
98
  end
@@ -99,37 +99,37 @@ module Cucumber
99
99
 
100
100
  observed_events = []
101
101
  execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new] do |event_bus|
102
- event_bus.on(:test_case_starting) do |event|
102
+ event_bus.on(:test_case_started) do |event|
103
103
  test_case = event.test_case
104
- observed_events << [:test_case_starting, test_case.name]
104
+ observed_events << [:test_case_started, test_case.name]
105
105
  end
106
106
  event_bus.on(:test_case_finished) do |event|
107
107
  test_case, result = *event.attributes
108
108
  observed_events << [:test_case_finished, test_case.name, result.to_sym]
109
109
  end
110
- event_bus.on(:test_step_starting) do |event|
110
+ event_bus.on(:test_step_started) do |event|
111
111
  test_step = event.test_step
112
- observed_events << [:test_step_starting, test_step.name]
112
+ observed_events << [:test_step_started, test_step.text]
113
113
  end
114
114
  event_bus.on(:test_step_finished) do |event|
115
115
  test_step, result = *event.attributes
116
- observed_events << [:test_step_finished, test_step.name, result.to_sym]
116
+ observed_events << [:test_step_finished, test_step.text, result.to_sym]
117
117
  end
118
118
  end
119
119
 
120
120
  expect(observed_events).to eq [
121
- [:test_case_starting, 'The one that passes'],
122
- [:test_step_starting, 'passing'],
121
+ [:test_case_started, 'The one that passes'],
122
+ [:test_step_started, 'passing'],
123
123
  [:test_step_finished, 'passing', :passed],
124
124
  [:test_case_finished, 'The one that passes', :passed],
125
- [:test_case_starting, 'The one that fails'],
126
- [:test_step_starting, 'passing'],
125
+ [:test_case_started, 'The one that fails'],
126
+ [:test_step_started, 'passing'],
127
127
  [:test_step_finished, 'passing', :passed],
128
- [:test_step_starting, 'failing'],
128
+ [:test_step_started, 'failing'],
129
129
  [:test_step_finished, 'failing', :failed],
130
- [:test_step_starting, 'passing'],
130
+ [:test_step_started, 'passing'],
131
131
  [:test_step_finished, 'passing', :skipped],
132
- [:test_step_starting, 'undefined'],
132
+ [:test_step_started, 'undefined'],
133
133
  [:test_step_finished, 'undefined', :undefined],
134
134
  [:test_case_finished, 'The one that fails', :failed],
135
135
  ]
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: 3.0.0.pre.2
4
+ version: 3.0.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: 2017-07-26 00:00:00.000000000 Z
15
+ date: 2017-09-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
@@ -167,9 +167,9 @@ files:
167
167
  - ".ruby-gemset"
168
168
  - ".travis.yml"
169
169
  - ".yardopts"
170
+ - CHANGELOG.md
170
171
  - CONTRIBUTING.md
171
172
  - Gemfile
172
- - HISTORY.md
173
173
  - LICENSE
174
174
  - README.md
175
175
  - Rakefile
@@ -262,15 +262,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
262
  version: 1.9.3
263
263
  required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  requirements:
265
- - - ">"
265
+ - - ">="
266
266
  - !ruby/object:Gem::Version
267
- version: 1.3.1
267
+ version: '0'
268
268
  requirements: []
269
269
  rubyforge_project:
270
- rubygems_version: 2.6.8
270
+ rubygems_version: 2.5.1
271
271
  signing_key:
272
272
  specification_version: 4
273
- summary: cucumber-core-3.0.0.pre.2
273
+ summary: cucumber-core-3.0.0
274
274
  test_files:
275
275
  - spec/capture_warnings.rb
276
276
  - spec/coverage.rb