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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/knapsack/adapters/cucumber_adapter.rb +12 -6
- data/lib/knapsack/version.rb +1 -1
- data/spec/knapsack/adapters/cucumber_adapter_spec.rb +68 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2e90b914f73323de26c0539169858e4e0ce4dad
|
4
|
+
data.tar.gz: 5b2ab7f2a542048f0837b57c0064b021eae864b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1cefe0b4388e834ea2a4fcf1b3a11889f613263548b7fb2122bfb956afbb9292266a9c56b0779b416c2c1b4bad84fc0f13d7f6bfa4c2ae3e6ab2fb374f086d5
|
7
|
+
data.tar.gz: fbd8a0d55183b73e7f923d3cd55f272dd8c38ce1bc587023d90274df70e420e02799e55e0150ce3a916068a47005e24ef405f3a59adcebe20adef5492b38a953
|
data/CHANGELOG.md
CHANGED
@@ -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 |
|
9
|
-
Knapsack.tracker.test_path = CucumberAdapter.test_path(
|
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(
|
34
|
-
if
|
35
|
-
|
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
|
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
|
|
data/lib/knapsack/version.rb
CHANGED
@@ -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
|
-
|
26
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
98
|
+
context 'when Cucumber version 1' do
|
99
|
+
subject { described_class.test_path(scenario_or_outline_table) }
|
72
100
|
|
73
|
-
|
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
|
-
|
78
|
-
|
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
|
-
|
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
|
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.
|
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:
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|