cucumber-core 1.1.3 → 1.2.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.
@@ -10,15 +10,16 @@ module Cucumber::Core::Test
10
10
  let(:source) { [double('ast node', location: double)] }
11
11
  let(:runner) { Runner.new(report) }
12
12
  let(:report) { double.as_null_object }
13
- let(:passing) { Step.new([double]).with_action {} }
14
- let(:failing) { Step.new([double]).with_action { raise exception } }
15
- let(:pending) { Step.new([double]).with_action { raise Result::Pending.new("TODO") } }
16
- let(:skipping) { Step.new([double]).with_action { raise Result::Skipped.new } }
17
- let(:undefined) { Step.new([double]) }
13
+ let(:passing) { Step.new([source]).with_action {} }
14
+ let(:failing) { Step.new([source]).with_action { raise exception } }
15
+ let(:pending) { Step.new([source]).with_action { raise Result::Pending.new("TODO") } }
16
+ let(:skipping) { Step.new([source]).with_action { raise Result::Skipped.new } }
17
+ let(:undefined) { Step.new([source]) }
18
18
  let(:exception) { StandardError.new('test error') }
19
19
 
20
20
  before do
21
21
  allow(report).to receive(:before_test_case)
22
+ allow(source).to receive(:location)
22
23
  end
23
24
 
24
25
  context "reporting the duration of a test case" do
@@ -100,6 +101,24 @@ module Cucumber::Core::Test
100
101
  expect( report ).to receive(:after_test_case) do |test_case, result|
101
102
  expect( result ).to be_undefined
102
103
  end
104
+ allow( undefined.source.last ).to receive(:name)
105
+ test_case.describe_to runner
106
+ end
107
+
108
+ it 'sets the message on the result' do
109
+ expect( report ).to receive(:after_test_case) do |test_case, result|
110
+ expect( result.message ).to eq("Undefined step: \"step name\"")
111
+ end
112
+ expect( undefined.source.last ).to receive(:name).and_return("step name")
113
+ test_case.describe_to runner
114
+ end
115
+
116
+ it 'appends the backtrace of the result' do
117
+ expect( report ).to receive(:after_test_case) do |test_case, result|
118
+ expect( result.backtrace ).to eq(["step line"])
119
+ end
120
+ expect( undefined.source.last ).to receive(:backtrace_line).and_return("step line")
121
+ allow( undefined.source.last ).to receive(:name)
103
122
  test_case.describe_to runner
104
123
  end
105
124
  end
@@ -113,6 +132,14 @@ module Cucumber::Core::Test
113
132
  end
114
133
  test_case.describe_to runner
115
134
  end
135
+
136
+ it 'appends the backtrace of the result' do
137
+ expect( report ).to receive(:after_test_case) do |test_case, result|
138
+ expect( result.backtrace.last ).to eq("step line")
139
+ end
140
+ expect( pending.source.last ).to receive(:backtrace_line).and_return("step line")
141
+ test_case.describe_to runner
142
+ end
116
143
  end
117
144
 
118
145
  context "a skipping step" do
@@ -124,6 +151,14 @@ module Cucumber::Core::Test
124
151
  end
125
152
  test_case.describe_to runner
126
153
  end
154
+
155
+ it 'appends the backtrace of the result' do
156
+ expect( report ).to receive(:after_test_case) do |test_case, result|
157
+ expect( result.backtrace.last ).to eq("step line")
158
+ end
159
+ expect( skipping.source.last ).to receive(:backtrace_line).and_return("step line")
160
+ test_case.describe_to runner
161
+ end
127
162
  end
128
163
 
129
164
  context 'that fail' do
@@ -135,6 +170,14 @@ module Cucumber::Core::Test
135
170
  end
136
171
  test_case.describe_to runner
137
172
  end
173
+
174
+ it 'appends the backtrace of the exception of the result' do
175
+ expect( report ).to receive(:after_test_case) do |test_case, result|
176
+ expect( result.exception.backtrace.last ).to eq("step line")
177
+ end
178
+ expect( failing.source.last ).to receive(:backtrace_line).and_return("step line")
179
+ test_case.describe_to runner
180
+ end
138
181
  end
139
182
 
140
183
  context 'where the first step fails' do
@@ -202,8 +245,8 @@ module Cucumber::Core::Test
202
245
  hook_mapping = UnskippableAction.new do |last_result|
203
246
  result_spy = last_result
204
247
  end
205
- after_hook = Step.new([double], hook_mapping)
206
- failing_step = Step.new([double]).with_action { fail }
248
+ after_hook = Step.new([source], hook_mapping)
249
+ failing_step = Step.new([source]).with_action { fail }
207
250
  test_case = Case.new([failing_step, after_hook], source)
208
251
  test_case.describe_to runner
209
252
  expect(result_spy).to be_failed
@@ -214,7 +257,7 @@ module Cucumber::Core::Test
214
257
  context "with around hooks" do
215
258
  it "passes normally when around hooks don't fail" do
216
259
  around_hook = AroundHook.new { |block| block.call }
217
- passing_step = Step.new([double]).with_action {}
260
+ passing_step = Step.new([source]).with_action {}
218
261
  test_case = Case.new([passing_step], source, [around_hook])
219
262
  expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
220
263
  expect(result).to be_passed
@@ -224,7 +267,7 @@ module Cucumber::Core::Test
224
267
 
225
268
  it "gets a failed result if the Around hook fails before the test case is run" do
226
269
  around_hook = AroundHook.new { |block| raise exception }
227
- passing_step = Step.new([double]).with_action {}
270
+ passing_step = Step.new([source]).with_action {}
228
271
  test_case = Case.new([passing_step], source, [around_hook])
229
272
  expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
230
273
  expect(result).to be_failed
@@ -235,7 +278,7 @@ module Cucumber::Core::Test
235
278
 
236
279
  it "gets a failed result if the Around hook fails after the test case is run" do
237
280
  around_hook = AroundHook.new { |block| block.call; raise exception }
238
- passing_step = Step.new([double]).with_action {}
281
+ passing_step = Step.new([source]).with_action {}
239
282
  test_case = Case.new([passing_step], source, [around_hook])
240
283
  expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
241
284
  expect(result).to be_failed
@@ -246,7 +289,7 @@ module Cucumber::Core::Test
246
289
 
247
290
  it "fails when a step fails if the around hook works" do
248
291
  around_hook = AroundHook.new { |block| block.call }
249
- failing_step = Step.new([double]).with_action { raise exception }
292
+ failing_step = Step.new([source]).with_action { raise exception }
250
293
  test_case = Case.new([failing_step], source, [around_hook])
251
294
  expect(report).to receive(:after_test_case).with(test_case, anything) do |reported_test_case, result|
252
295
  expect(result).to be_failed
@@ -4,16 +4,21 @@ module Cucumber::Core::Test
4
4
  describe Step do
5
5
 
6
6
  describe "describing itself" do
7
+ let(:step_or_hook) { double }
8
+ before(:each) do
9
+ allow( step_or_hook ).to receive(:location)
10
+ end
11
+
7
12
  it "describes itself to a visitor" do
8
13
  visitor = double
9
14
  args = double
10
- test_step = Step.new([double])
15
+ test_step = Step.new([step_or_hook])
11
16
  expect( visitor ).to receive(:test_step).with(test_step, args)
12
17
  test_step.describe_to(visitor, args)
13
18
  end
14
19
 
15
20
  it "describes its source to a visitor" do
16
- feature, scenario, step_or_hook = double, double, double
21
+ feature, scenario = double, double
17
22
  visitor = double
18
23
  args = double
19
24
  expect( feature ).to receive(:describe_to).with(visitor, args)
@@ -26,6 +31,9 @@ module Cucumber::Core::Test
26
31
 
27
32
  describe "executing" do
28
33
  let(:ast_step) { double }
34
+ before(:each) do
35
+ allow( ast_step ).to receive(:location)
36
+ end
29
37
 
30
38
  it "passes arbitrary arguments to the action's block" do
31
39
  args_spy = nil
@@ -72,5 +80,12 @@ module Cucumber::Core::Test
72
80
  expect( test_step.location ).to eq location
73
81
  end
74
82
 
83
+ it "exposes the location of the action as attribute" do
84
+ location = double
85
+ action = double(location: location)
86
+ test_step = Step.new([double], action)
87
+ expect( test_step.action_location ).to eq location
88
+ end
89
+
75
90
  end
76
91
  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.1.3
4
+ version: 1.2.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: 2015-03-25 00:00:00.000000000 Z
15
+ date: 2015-07-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
@@ -218,7 +218,7 @@ rubyforge_project:
218
218
  rubygems_version: 2.2.2
219
219
  signing_key:
220
220
  specification_version: 4
221
- summary: cucumber-core-1.1.3
221
+ summary: cucumber-core-1.2.0
222
222
  test_files:
223
223
  - spec/capture_warnings.rb
224
224
  - spec/coverage.rb
@@ -245,3 +245,4 @@ test_files:
245
245
  - spec/cucumber/core_spec.rb
246
246
  - spec/readme_spec.rb
247
247
  - spec/report_api_spy.rb
248
+ has_rdoc: