knapsack 1.5.1 → 1.6.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: 3e0c6e0155db9874413db7e03df64a0f62c8f185
4
- data.tar.gz: a668e3c36473d5c6422352974b546de613e12dca
3
+ metadata.gz: d2e90b914f73323de26c0539169858e4e0ce4dad
4
+ data.tar.gz: 5b2ab7f2a542048f0837b57c0064b021eae864b2
5
5
  SHA512:
6
- metadata.gz: 62b7636c2a124a66bb7e794a55cf1af786f98a5991dbdec997a1ff9b0f8b4d189f2e12c11958598ecd68305e01df515e398eb59b0ce1bf88023033b2f6107df5
7
- data.tar.gz: df7ac31711b33ea9b2252fe67fb2e88ec75db0679e43154adb74587456feaad26b7ad173705361ba7e7fd05547875b7392eb725e8644281b0deccbf711121861
6
+ metadata.gz: c1cefe0b4388e834ea2a4fcf1b3a11889f613263548b7fb2122bfb956afbb9292266a9c56b0779b416c2c1b4bad84fc0f13d7f6bfa4c2ae3e6ab2fb374f086d5
7
+ data.tar.gz: fbd8a0d55183b73e7f923d3cd55f272dd8c38ce1bc587023d90274df70e420e02799e55e0150ce3a916068a47005e24ef405f3a59adcebe20adef5492b38a953
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.6.0
6
+
7
+ * Add support for Cucumber 2
8
+
9
+ https://github.com/ArturT/knapsack/issues/30
10
+
11
+ https://github.com/ArturT/knapsack/compare/v1.5.1...v1.6.0
12
+
5
13
  ### 1.5.1
6
14
 
7
15
  * Add link to FAQ at the end of time offset warning
@@ -5,8 +5,8 @@ module Knapsack
5
5
  REPORT_PATH = 'knapsack_cucumber_report.json'
6
6
 
7
7
  def bind_time_tracker
8
- Around do |scenario_or_outline_table, block|
9
- Knapsack.tracker.test_path = CucumberAdapter.test_path(scenario_or_outline_table)
8
+ Around do |object, block|
9
+ Knapsack.tracker.test_path = CucumberAdapter.test_path(object)
10
10
  Knapsack.tracker.start_timer
11
11
  block.call
12
12
  Knapsack.tracker.stop_timer
@@ -30,11 +30,17 @@ module Knapsack
30
30
  end
31
31
  end
32
32
 
33
- def self.test_path(scenario_or_outline_table)
34
- if scenario_or_outline_table.respond_to?(:file)
35
- scenario_or_outline_table.file
33
+ def self.test_path(object)
34
+ if Cucumber::VERSION.to_i >= 2
35
+ test_case = object
36
+ test_case.location.file
36
37
  else
37
- scenario_or_outline_table.scenario_outline.file
38
+ scenario_or_outline_table = object
39
+ if scenario_or_outline_table.respond_to?(:file)
40
+ scenario_or_outline_table.file
41
+ else
42
+ scenario_or_outline_table.scenario_outline.file
43
+ end
38
44
  end
39
45
  end
40
46
 
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '1.5.1'
2
+ VERSION = '1.6.0'
3
3
  end
@@ -9,32 +9,59 @@ describe Knapsack::Adapters::CucumberAdapter do
9
9
  end
10
10
 
11
11
  describe 'bind methods' do
12
- let(:file) { 'features/a.feature' }
13
- let(:scenario) { double(file: file) }
14
- let(:block) { double }
15
12
  let(:logger) { instance_double(Knapsack::Logger) }
16
- let(:global_time) { 'Global time: 01m 05s' }
17
13
 
18
14
  before do
19
15
  expect(Knapsack).to receive(:logger).and_return(logger)
20
16
  end
21
17
 
22
18
  describe '#bind_time_tracker' do
19
+ let(:file) { 'features/a.feature' }
20
+ let(:block) { double }
21
+ let(:global_time) { 'Global time: 01m 05s' }
23
22
  let(:tracker) { instance_double(Knapsack::Tracker) }
24
23
 
25
- it do
26
- expect(subject).to receive(:Around).and_yield(scenario, block)
27
- allow(Knapsack).to receive(:tracker).and_return(tracker)
28
- expect(tracker).to receive(:test_path=).with(file)
29
- expect(tracker).to receive(:start_timer)
30
- expect(block).to receive(:call)
31
- expect(tracker).to receive(:stop_timer)
24
+ context 'when Cucumber version 1' do
25
+ let(:scenario) { double(file: file) }
32
26
 
33
- expect(::Kernel).to receive(:at_exit).and_yield
34
- expect(Knapsack::Presenter).to receive(:global_time).and_return(global_time)
35
- expect(logger).to receive(:info).with(global_time)
27
+ before { stub_const('Cucumber::VERSION', '1.3.20') }
28
+
29
+ it do
30
+ expect(subject).to receive(:Around).and_yield(scenario, block)
31
+ allow(Knapsack).to receive(:tracker).and_return(tracker)
32
+ expect(tracker).to receive(:test_path=).with(file)
33
+ expect(tracker).to receive(:start_timer)
34
+ expect(block).to receive(:call)
35
+ expect(tracker).to receive(:stop_timer)
36
+
37
+ expect(::Kernel).to receive(:at_exit).and_yield
38
+ expect(Knapsack::Presenter).to receive(:global_time).and_return(global_time)
39
+ expect(logger).to receive(:info).with(global_time)
40
+
41
+ subject.bind_time_tracker
42
+ end
43
+ end
44
+
45
+ context 'when Cucumber version 2' do
46
+ let(:test_case) { double(location: double(file: file)) }
47
+
48
+ # complex version name to ensure we can catch that too
49
+ before { stub_const('Cucumber::VERSION', '2.0.0.rc.5') }
50
+
51
+ it do
52
+ expect(subject).to receive(:Around).and_yield(test_case, block)
53
+ allow(Knapsack).to receive(:tracker).and_return(tracker)
54
+ expect(tracker).to receive(:test_path=).with(file)
55
+ expect(tracker).to receive(:start_timer)
56
+ expect(block).to receive(:call)
57
+ expect(tracker).to receive(:stop_timer)
36
58
 
37
- subject.bind_time_tracker
59
+ expect(::Kernel).to receive(:at_exit).and_yield
60
+ expect(Knapsack::Presenter).to receive(:global_time).and_return(global_time)
61
+ expect(logger).to receive(:info).with(global_time)
62
+
63
+ subject.bind_time_tracker
64
+ end
38
65
  end
39
66
  end
40
67
 
@@ -68,22 +95,37 @@ describe Knapsack::Adapters::CucumberAdapter do
68
95
  end
69
96
 
70
97
  describe '.test_path' do
71
- subject { described_class.test_path(scenario_or_outline_table) }
98
+ context 'when Cucumber version 1' do
99
+ subject { described_class.test_path(scenario_or_outline_table) }
72
100
 
73
- context 'when scenario' do
74
- let(:scenario_file) { 'features/scenario.feature' }
75
- let(:scenario_or_outline_table) { double(file: scenario_file) }
101
+ before { stub_const('Cucumber::VERSION', '1') }
76
102
 
77
- it { should eql scenario_file }
78
- end
103
+ context 'when scenario' do
104
+ let(:scenario_file) { 'features/scenario.feature' }
105
+ let(:scenario_or_outline_table) { double(file: scenario_file) }
106
+
107
+ it { should eql scenario_file }
108
+ end
109
+
110
+ context 'when scenario outline' do
111
+ let(:scenario_outline_file) { 'features/scenario_outline.feature' }
112
+ let(:scenario_or_outline_table) do
113
+ double(scenario_outline: double(file: scenario_outline_file))
114
+ end
79
115
 
80
- context 'when scenario outline' do
81
- let(:scenario_outline_file) { 'features/scenario_outline.feature' }
82
- let(:scenario_or_outline_table) do
83
- double(scenario_outline: double(file: scenario_outline_file))
116
+ it { should eql scenario_outline_file }
84
117
  end
118
+ end
119
+
120
+ context 'when Cucumber version 2' do
121
+ let(:file) { 'features/a.feature' }
122
+ let(:test_case) { double(location: double(file: file)) } # Cucumber 2
123
+
124
+ subject { described_class.test_path(test_case) }
125
+
126
+ before { stub_const('Cucumber::VERSION', '2') }
85
127
 
86
- it { should eql scenario_outline_file }
128
+ it { should eql file }
87
129
  end
88
130
  end
89
131
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-23 00:00:00.000000000 Z
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake