cucumber-core 1.1.1 → 1.1.2

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: 5e74d19b9afa811f9bb89519680da05fb54e4f21
4
- data.tar.gz: 51423664d262bb30d820712a52ff8c5dcbd2b43e
3
+ metadata.gz: 3f3a3d2a1c3f4b18449225549d35fedcf56dde29
4
+ data.tar.gz: d7ea03f3906eb56001fd04625875d17a45711680
5
5
  SHA512:
6
- metadata.gz: 11c262271fe0041e39e9e0c6a400ea3d5de63c702ff528edae821dfba99fa7408c26a61ae6c4093be79ec596805465fbd2d9c31a9b7bc8eef1a8b2a9cad64a58
7
- data.tar.gz: ea0a43a32a8566e51cae8d90c8831ca3af9e42fd48da76d12c586754973ede208a33df577e39b0afa98afedc3ad1dbe3aebc443669540a7132af09e1ce8e2fc2
6
+ metadata.gz: 066615ed100d54bf46fc955adc8bc7e1b52b4e9617d82247b436baf3138f05ada07afdeb4f1f5767787cb97fc4f299ddb03a09d48129f92cc79144e88257bb98
7
+ data.tar.gz: 1a2e6cef1e122116f914087cb44b9e01884ea0c6de67c7c3fb045267db93fc37ff976e5c0aebf33db5540829ede1209512bfd5e341de3cd2b945d71c0a6f85ed
data/HISTORY.md CHANGED
@@ -1,9 +1,14 @@
1
1
  ## [In Git](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.1...master)
2
2
 
3
- * Your change here?
3
+ ### New Features
4
+
5
+ * Make Test Case names for Scenario Outlines language neutral [83](https://github.com/cucumber/cucumber-ruby-core/pull/83) (@brasmusson)
6
+ * Add predicate methods for Multline arguments (@mattwynne)
7
+ * Expose `Test::Case#feature` (@mattwynne)
8
+ * Fail test case if around hook fails (@mattwynne, @tooky)
9
+ * Expose `Test::Case#around_hooks` (@tooky)
4
10
 
5
- ##
6
- [v1.1.1](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.1...v1.1.1)
11
+ ## [v1.1.1](https://github.com/cucumber/cucumber-ruby-core/compare/v1.1.0...v1.1.1)
7
12
 
8
13
 
9
14
  ### New Features
@@ -49,6 +49,14 @@ module Cucumber
49
49
  dup
50
50
  end
51
51
 
52
+ def data_table?
53
+ true
54
+ end
55
+
56
+ def doc_string?
57
+ false
58
+ end
59
+
52
60
  # Creates a copy of this table
53
61
  #
54
62
  def dup
@@ -33,6 +33,14 @@ module Cucumber
33
33
  super @content
34
34
  end
35
35
 
36
+ def data_table?
37
+ false
38
+ end
39
+
40
+ def doc_string?
41
+ true
42
+ end
43
+
36
44
  def map
37
45
  raise ArgumentError, "No block given" unless block_given?
38
46
  new_content = yield content
@@ -6,6 +6,14 @@ module Cucumber
6
6
  self
7
7
  end
8
8
 
9
+ def data_table?
10
+ false
11
+ end
12
+
13
+ def doc_string?
14
+ false
15
+ end
16
+
9
17
  def map(&block)
10
18
  self
11
19
  end
@@ -4,14 +4,26 @@ module Cucumber
4
4
  class AroundHook
5
5
  def initialize(&block)
6
6
  @block = block
7
+ @timer = Timer.new
7
8
  end
8
9
 
9
10
  def describe_to(visitor, *args, &continue)
10
11
  visitor.around_hook(self, *args, &continue)
11
12
  end
12
13
 
13
- def call(continue)
14
+ def execute(*args, &continue)
15
+ @timer.start
14
16
  @block.call(continue)
17
+ Result::Unknown.new # Around hook does not know the result of the inner test steps
18
+ rescue Result::Raisable => exception
19
+ exception.with_duration(@timer.duration)
20
+ rescue Exception => exception
21
+ failed(exception)
22
+ end
23
+
24
+ private
25
+ def failed(exception)
26
+ Result::Failed.new(@timer.duration, exception)
15
27
  end
16
28
  end
17
29
  end
@@ -5,7 +5,6 @@ module Cucumber
5
5
  module Test
6
6
  class Case
7
7
  attr_reader :source, :test_steps, :around_hooks
8
- private :around_hooks
9
8
 
10
9
  def initialize(test_steps, source, around_hooks = [])
11
10
  raise ArgumentError.new("test_steps should be an Array but is a #{test_steps.class}") unless test_steps.kind_of?(Array)
@@ -82,6 +81,10 @@ module Cucumber
82
81
  "<#{self.class}: #{location}>"
83
82
  end
84
83
 
84
+ def feature
85
+ source.first
86
+ end
87
+
85
88
  private
86
89
 
87
90
  def compose_around_hooks(visitor, *args, &block)
@@ -90,10 +93,6 @@ module Cucumber
90
93
  end.call
91
94
  end
92
95
 
93
- def feature
94
- source.first
95
- end
96
-
97
96
  class NameBuilder
98
97
  attr_reader :result
99
98
  attr_reader :keyword
@@ -126,7 +125,7 @@ module Cucumber
126
125
  end
127
126
 
128
127
  def examples_table_row(row)
129
- @result = " (row #{row.number})"
128
+ @result = " (##{row.number})"
130
129
  self
131
130
  end
132
131
  end
@@ -27,7 +27,7 @@ module Cucumber
27
27
  end
28
28
 
29
29
  def around_hook(hook, &continue)
30
- hook.call(continue)
30
+ running_test_case.execute(hook, &continue)
31
31
  self
32
32
  end
33
33
 
@@ -42,8 +42,8 @@ module Cucumber
42
42
  @status = Status::Unknown.new(Result::Unknown.new)
43
43
  end
44
44
 
45
- def execute(test_step)
46
- status.execute(test_step, self)
45
+ def execute(test_step, &continue)
46
+ status.execute(test_step, self, &continue)
47
47
  end
48
48
 
49
49
  def result
@@ -95,8 +95,8 @@ module Cucumber
95
95
  @step_result = step_result
96
96
  end
97
97
 
98
- def execute(test_step, monitor)
99
- result = test_step.execute(monitor.result)
98
+ def execute(test_step, monitor, &continue)
99
+ result = test_step.execute(monitor.result, &continue)
100
100
  result.describe_to(monitor, result)
101
101
  end
102
102
 
@@ -118,7 +118,7 @@ module Cucumber
118
118
  end
119
119
 
120
120
  class Failing < Base
121
- def execute(test_step, monitor)
121
+ def execute(test_step, monitor, &continue)
122
122
  test_step.skip(monitor.result)
123
123
  end
124
124
 
@@ -2,7 +2,7 @@ module Cucumber
2
2
  module Core
3
3
  class Version
4
4
  def self.to_s
5
- "1.1.1"
5
+ "1.1.2"
6
6
  end
7
7
  end
8
8
  end
@@ -28,6 +28,22 @@ module Cucumber
28
28
  end
29
29
  end
30
30
 
31
+ describe "#data_table?" do
32
+ let(:table) { DataTable.new([[1,2],[3,4]], location) }
33
+
34
+ it "returns true" do
35
+ expect(table).to be_data_table
36
+ end
37
+ end
38
+
39
+ describe "#doc_string" do
40
+ let(:table) { DataTable.new([[1,2],[3,4]], location) }
41
+
42
+ it "returns false" do
43
+ expect(table).not_to be_doc_string
44
+ end
45
+ end
46
+
31
47
  describe "#map" do
32
48
  let(:table) { DataTable.new([ %w{foo bar}, %w{1 2} ], location) }
33
49
 
@@ -8,6 +8,22 @@ module Cucumber
8
8
  let(:location) { double }
9
9
  let(:doc_string) { DocString.new(content, content_type, location) }
10
10
 
11
+ describe "#data_table?" do
12
+ let(:doc_string) { DocString.new("test", "text/plain" , location) }
13
+
14
+ it "returns false" do
15
+ expect(doc_string).not_to be_data_table
16
+ end
17
+ end
18
+
19
+ describe "#doc_string" do
20
+ let(:doc_string) { DocString.new("test", "text/plain" , location) }
21
+
22
+ it "returns true" do
23
+ expect(doc_string).to be_doc_string
24
+ end
25
+ end
26
+
11
27
  context '#map' do
12
28
  let(:content) { 'original content' }
13
29
  let(:content_type) { double }
@@ -0,0 +1,27 @@
1
+ require 'cucumber/core/ast/location'
2
+ require 'cucumber/core/ast/empty_multiline_argument'
3
+
4
+ module Cucumber
5
+ module Core
6
+ module Ast
7
+ describe EmptyMultilineArgument do
8
+
9
+ let(:location) { double }
10
+ let(:arg) { EmptyMultilineArgument.new }
11
+
12
+ describe "#data_table?" do
13
+ it "returns false" do
14
+ expect(arg).not_to be_data_table
15
+ end
16
+ end
17
+
18
+ describe "#doc_string" do
19
+ it "returns false" do
20
+ expect(arg).not_to be_doc_string
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -97,14 +97,14 @@ module Cucumber
97
97
  end
98
98
  receiver = double.as_null_object
99
99
  expect( receiver ).to receive(:test_case) do |test_case|
100
- expect( test_case.name ).to eq 'outline name, examples name (row 1)'
100
+ expect( test_case.name ).to eq 'outline name, examples name (#1)'
101
101
  expect( test_case.keyword ).to eq 'Scenario Outline'
102
102
  end.once.ordered
103
103
  expect( receiver ).to receive(:test_case) do |test_case|
104
- expect( test_case.name ).to eq 'outline name, examples name (row 2)'
104
+ expect( test_case.name ).to eq 'outline name, examples name (#2)'
105
105
  end.once.ordered
106
106
  expect( receiver ).to receive(:test_case) do |test_case|
107
- expect( test_case.name ).to eq 'outline name, Examples (row 1)'
107
+ expect( test_case.name ).to eq 'outline name, Examples (#1)'
108
108
  end.once.ordered
109
109
  compile [gherkin], receiver
110
110
  end
@@ -378,7 +378,7 @@ module Cucumber
378
378
  end
379
379
 
380
380
  let(:test_case) do
381
- test_cases.find { |c| c.name == "two, x1 (row 1)" }
381
+ test_cases.find { |c| c.name == "two, x1 (#1)" }
382
382
  end
383
383
 
384
384
  it 'matches the precise location of the scenario outline examples table row' do
@@ -7,7 +7,7 @@ module Cucumber::Core::Test
7
7
  describe Runner do
8
8
 
9
9
  let(:test_case) { Case.new(test_steps, source) }
10
- let(:source) { double }
10
+ let(:source) { [double('ast node', location: double)] }
11
11
  let(:runner) { Runner.new(report) }
12
12
  let(:report) { double.as_null_object }
13
13
  let(:passing) { Step.new([double]).with_action {} }
@@ -210,5 +210,51 @@ module Cucumber::Core::Test
210
210
  end
211
211
  end
212
212
 
213
+ require 'cucumber/core/test/around_hook'
214
+ context "with around hooks" do
215
+ it "passes normally when around hooks don't fail" do
216
+ around_hook = AroundHook.new { |block| block.call }
217
+ passing_step = Step.new([double]).with_action {}
218
+ test_case = Case.new([passing_step], source, [around_hook])
219
+ expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
220
+ expect(result).to be_passed
221
+ end
222
+ test_case.describe_to runner
223
+ end
224
+
225
+ it "gets a failed result if the Around hook fails before the test case is run" do
226
+ around_hook = AroundHook.new { |block| raise exception }
227
+ passing_step = Step.new([double]).with_action {}
228
+ test_case = Case.new([passing_step], source, [around_hook])
229
+ expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
230
+ expect(result).to be_failed
231
+ expect(result.exception).to eq exception
232
+ end
233
+ test_case.describe_to runner
234
+ end
235
+
236
+ it "gets a failed result if the Around hook fails after the test case is run" do
237
+ around_hook = AroundHook.new { |block| block.call; raise exception }
238
+ passing_step = Step.new([double]).with_action {}
239
+ test_case = Case.new([passing_step], source, [around_hook])
240
+ expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
241
+ expect(result).to be_failed
242
+ expect(result.exception).to eq exception
243
+ end
244
+ test_case.describe_to runner
245
+ end
246
+
247
+ it "fails when a step fails if the around hook works" do
248
+ around_hook = AroundHook.new { |block| block.call }
249
+ failing_step = Step.new([double]).with_action { raise exception }
250
+ test_case = Case.new([failing_step], source, [around_hook])
251
+ expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
252
+ expect(result).to be_failed
253
+ expect(result.exception).to eq exception
254
+ end
255
+ test_case.describe_to runner
256
+ end
257
+ end
258
+
213
259
  end
214
260
  end
@@ -48,7 +48,7 @@ module Cucumber
48
48
  it "filters out test cases based on a tag expression" do
49
49
  visitor = double.as_null_object
50
50
  expect( visitor ).to receive(:test_case) do |test_case|
51
- expect( test_case.name ).to eq 'foo, bar (row 1)'
51
+ expect( test_case.name ).to eq 'foo, bar (#1)'
52
52
  end.exactly(1).times
53
53
 
54
54
  gherkin = gherkin do
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.1.1
4
+ version: 1.1.2
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: 2015-02-13 00:00:00.000000000 Z
15
+ date: 2015-03-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
@@ -173,6 +173,7 @@ files:
173
173
  - spec/coverage.rb
174
174
  - spec/cucumber/core/ast/data_table_spec.rb
175
175
  - spec/cucumber/core/ast/doc_string_spec.rb
176
+ - spec/cucumber/core/ast/empty_multiline_argument_spec.rb
176
177
  - spec/cucumber/core/ast/examples_table_spec.rb
177
178
  - spec/cucumber/core/ast/location_spec.rb
178
179
  - spec/cucumber/core/ast/outline_step_spec.rb
@@ -216,12 +217,13 @@ rubyforge_project:
216
217
  rubygems_version: 2.2.2
217
218
  signing_key:
218
219
  specification_version: 4
219
- summary: cucumber-core-1.1.1
220
+ summary: cucumber-core-1.1.2
220
221
  test_files:
221
222
  - spec/capture_warnings.rb
222
223
  - spec/coverage.rb
223
224
  - spec/cucumber/core/ast/data_table_spec.rb
224
225
  - spec/cucumber/core/ast/doc_string_spec.rb
226
+ - spec/cucumber/core/ast/empty_multiline_argument_spec.rb
225
227
  - spec/cucumber/core/ast/examples_table_spec.rb
226
228
  - spec/cucumber/core/ast/location_spec.rb
227
229
  - spec/cucumber/core/ast/outline_step_spec.rb