rspeed 0.1.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +11 -7
- data/lib/generators/rspeed/install_generator.rb +1 -1
- data/lib/rspeed.rb +9 -5
- data/lib/rspeed/env.rb +43 -0
- data/lib/rspeed/extension.rb +6 -37
- data/lib/rspeed/logger.rb +11 -0
- data/lib/rspeed/observer.rb +43 -0
- data/lib/rspeed/redis.rb +55 -0
- data/lib/rspeed/runner.rb +4 -17
- data/lib/rspeed/splitter.rb +65 -73
- data/lib/rspeed/variable.rb +31 -0
- data/lib/rspeed/version.rb +1 -1
- data/spec/common_helper.rb +10 -0
- data/spec/fixtures/1_spec.rb +9 -0
- data/spec/fixtures/2_spec.rb +5 -0
- data/spec/fixtures/empty.rb +4 -0
- data/spec/fixtures/new_spec.rb.csv +1 -0
- data/spec/models/rspeed/env/db_spec.rb +17 -0
- data/spec/models/rspeed/env/host_spec.rb +17 -0
- data/spec/models/rspeed/env/name_spec.rb +17 -0
- data/spec/models/rspeed/env/pipe_spec.rb +19 -0
- data/spec/models/rspeed/env/pipes_spec.rb +19 -0
- data/spec/models/rspeed/env/port_spec.rb +17 -0
- data/spec/models/rspeed/env/result_key_spec.rb +19 -0
- data/spec/models/rspeed/env/rspeed_spec.rb +43 -0
- data/spec/models/rspeed/env/tmp_spec.rb +19 -0
- data/spec/models/rspeed/observer/after_spec.rb +16 -0
- data/spec/models/rspeed/observer/after_suite_spec.rb +70 -0
- data/spec/models/rspeed/observer/before_spec.rb +15 -0
- data/spec/models/rspeed/observer/before_suite_spec.rb +37 -0
- data/spec/models/rspeed/redis/clean_spec.rb +12 -0
- data/spec/models/rspeed/redis/client_spec.rb +7 -0
- data/spec/models/rspeed/redis/destroy_spec.rb +29 -0
- data/spec/models/rspeed/redis/get_spec.rb +9 -0
- data/spec/models/rspeed/redis/keys_spec.rb +29 -0
- data/spec/models/rspeed/redis/result_spec.rb +13 -0
- data/spec/models/rspeed/redis/set_spec.rb +9 -0
- data/spec/models/rspeed/redis/specs_finished_spec.rb +19 -0
- data/spec/models/rspeed/redis/specs_initiated_spec.rb +13 -0
- data/spec/models/rspeed/runner/run_spec.rb +47 -0
- data/spec/models/rspeed/splitter/actual_examples_spec.rb +26 -0
- data/spec/models/rspeed/splitter/append_question_spec.rb +37 -0
- data/spec/models/rspeed/splitter/append_spec.rb +6 -3
- data/spec/models/rspeed/splitter/diff_spec.rb +15 -14
- data/spec/models/rspeed/splitter/first_pipe_spec.rb +2 -4
- data/spec/models/rspeed/splitter/get_spec.rb +7 -9
- data/spec/models/rspeed/splitter/need_warm_question_spec.rb +37 -0
- data/spec/models/rspeed/splitter/pipe_files_spec.rb +26 -0
- data/spec/models/rspeed/splitter/rename_spec.rb +3 -5
- data/spec/models/rspeed/splitter/split_spec.rb +72 -36
- data/spec/models/rspeed/variable/append_name_spec.rb +19 -0
- data/spec/models/rspeed/variable/csv_spec.rb +5 -0
- data/spec/models/rspeed/variable/default_partner_spec.rb +5 -0
- data/spec/models/rspeed/variable/key_spec.rb +15 -0
- data/spec/models/rspeed/variable/pipe_name_spec.rb +15 -0
- data/spec/models/rspeed/variable/pipes_pattern_spec.rb +5 -0
- data/spec/models/rspeed/variable/result_spec.rb +19 -0
- data/spec/models/rspeed/variable/tmp_spec.rb +15 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/common.rb +13 -0
- data/spec/support/coverage.rb +14 -0
- data/spec/support/env_mock.rb +3 -0
- data/spec/support/fakeredis.rb +3 -0
- metadata +155 -20
- data/spec/models/rspeed/splitter/destroy_spec.rb +0 -33
- data/spec/models/rspeed/splitter/keys_spec.rb +0 -33
- data/spec/models/rspeed/splitter/last_pipe_spec.rb +0 -21
- data/spec/models/rspeed/splitter/pipe_spec.rb +0 -21
- data/spec/models/rspeed/splitter/pipes_spec.rb +0 -27
- data/spec/models/rspeed/splitter/result_spec.rb +0 -19
- data/spec/models/rspeed/splitter/save_spec.rb +0 -55
- data/spec/rails_helper.rb +0 -24
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Redis, '#destroy' do
|
4
|
+
let!(:redis) { described_class }
|
5
|
+
|
6
|
+
before do
|
7
|
+
redis.set('rspeed', '{}')
|
8
|
+
redis.set('rspeed_1', '{}')
|
9
|
+
redis.set('rspeed_2', '{}')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'destroys via wildcard' do
|
13
|
+
redis.destroy('rspeed_*')
|
14
|
+
|
15
|
+
expect(redis.keys('*')).to eq %w[rspeed]
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'destroys via single name' do
|
19
|
+
redis.destroy('rspeed')
|
20
|
+
|
21
|
+
expect(redis.keys('*')).to eq %w[rspeed_1 rspeed_2]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'destroys default partner when no pattern is given' do
|
25
|
+
redis.destroy
|
26
|
+
|
27
|
+
expect(redis.keys('*')).to eq %w[rspeed]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Redis, '.keys' do
|
4
|
+
subject(:redis) { described_class }
|
5
|
+
|
6
|
+
context 'with default config' do
|
7
|
+
before do
|
8
|
+
described_class.set('rspeed_1', 'value_1')
|
9
|
+
described_class.set('rspeed_2', 'value_2')
|
10
|
+
described_class.set('rspeed_3', 'value_3')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'shows keys' do
|
14
|
+
expect(redis.keys).to eq %w[rspeed_1 rspeed_2 rspeed_3]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with custom key' do
|
19
|
+
before do
|
20
|
+
described_class.set('custom_key_1', 'value_1')
|
21
|
+
described_class.set('custom_key_2', 'value_2')
|
22
|
+
described_class.set('custom_key_3', 'value_3')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'shows keys' do
|
26
|
+
expect(redis.keys('custom_key_*')).to eq %w[custom_key_1 custom_key_2 custom_key_3]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Redis, '#result?' do
|
4
|
+
context 'when has no key rspeed on redis' do
|
5
|
+
it { expect(described_class.result?).to be(false) }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'when has key rspeed on redis' do
|
9
|
+
before { described_class.set('rspeed', { files: [[1, '1_spec.rb']], number: 0, total: 1 }.to_json) }
|
10
|
+
|
11
|
+
it { expect(described_class.result?).to be(true) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Redis, '.specs_finished?' do
|
4
|
+
before do
|
5
|
+
described_class.set('rspeed_pipe_1', '1.0')
|
6
|
+
|
7
|
+
allow(RSpeed::Env).to receive(:pipes).and_return(2)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when the quantity of pipe result is not the same as the quantity of pipes' do
|
11
|
+
it { expect(described_class.specs_finished?).to be(false) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when the quantity of pipe result is the same as the quantity of pipes' do
|
15
|
+
before { described_class.set('rspeed_pipe_2', '2.0') }
|
16
|
+
|
17
|
+
it { expect(described_class.specs_finished?).to be(true) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Redis, '.specs_initiated?' do
|
4
|
+
context 'when has no pipe flag key' do
|
5
|
+
it { expect(described_class.specs_finished?).to be(false) }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'when has at least one pipe flag key' do
|
9
|
+
before { described_class.set('rspeed_pipe_1', '1.0') }
|
10
|
+
|
11
|
+
it { expect(described_class.specs_finished?).to be(true) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Runner, '#run' do
|
4
|
+
let!(:shell) { double('shell') }
|
5
|
+
let!(:splitter) { instance_double('RSpeed::Splitter') }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(shell).to receive(:call)
|
9
|
+
allow(RSpeed::Splitter).to receive(:new).and_return(splitter)
|
10
|
+
allow(RSpeed::Observer).to receive(:after_suite)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when does not need warm' do
|
14
|
+
before { allow(splitter).to receive(:need_warm?).and_return(false) }
|
15
|
+
|
16
|
+
it 'does not run the specs' do
|
17
|
+
described_class.run(shell)
|
18
|
+
|
19
|
+
expect(shell).not_to have_received(:call)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'executes the after suite to complete the current pipe' do
|
23
|
+
described_class.run(shell)
|
24
|
+
|
25
|
+
expect(RSpeed::Observer).to have_received(:after_suite)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when need warm' do
|
30
|
+
before do
|
31
|
+
allow(splitter).to receive(:need_warm?).and_return(true)
|
32
|
+
allow(splitter).to receive(:pipe_files).and_return('spec_1.rb spec_2.rb')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'run the pipe specs' do
|
36
|
+
described_class.run(shell)
|
37
|
+
|
38
|
+
expect(shell).to have_received(:call).with('bundle exec rspec spec_1.rb spec_2.rb')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'does not execute the after suite to complete the current pipe' do
|
42
|
+
described_class.run(shell)
|
43
|
+
|
44
|
+
expect(RSpeed::Observer).not_to have_received(:after_suite)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Splitter, '#actual_examples' do
|
4
|
+
it 'returns all examples' do
|
5
|
+
splitter = described_class.new(specs_path: 'spec/fixtures/**/*_spec.rb')
|
6
|
+
|
7
|
+
expect(splitter.actual_examples).to eq [
|
8
|
+
'spec/fixtures/1_spec.rb:4',
|
9
|
+
'spec/fixtures/1_spec.rb:6',
|
10
|
+
'spec/fixtures/1_spec.rb:8',
|
11
|
+
'spec/fixtures/2_spec.rb:4',
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does not raise when no file match' do
|
16
|
+
splitter = described_class.new(specs_path: 'spec/fixtures/**/*_missing.rb')
|
17
|
+
|
18
|
+
expect(splitter.actual_examples).to eq []
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not raise when file is empty' do
|
22
|
+
splitter = described_class.new(specs_path: 'spec/fixtures/**/empty.rb')
|
23
|
+
|
24
|
+
expect(splitter.actual_examples).to eq []
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Splitter, '#append?' do
|
4
|
+
subject(:splitter) { described_class.new }
|
5
|
+
|
6
|
+
context 'when has no result' do
|
7
|
+
before { allow(RSpeed::Redis).to receive(:result?).and_return(false) }
|
8
|
+
|
9
|
+
context 'when is not the first pipe' do
|
10
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(false) }
|
11
|
+
|
12
|
+
it { expect(splitter.append?).to be(false) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when is the first pipe' do
|
16
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(true) }
|
17
|
+
|
18
|
+
it { expect(splitter.append?).to be(true) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when has result' do
|
23
|
+
before { allow(RSpeed::Redis).to receive(:result?).and_return(true) }
|
24
|
+
|
25
|
+
context 'when is not the first pipe' do
|
26
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(false) }
|
27
|
+
|
28
|
+
it { expect(splitter.append?).to be(true) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when is the first pipe' do
|
32
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(true) }
|
33
|
+
|
34
|
+
it { expect(splitter.append?).to be(true) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
3
|
RSpec.describe RSpeed::Splitter, '#append' do
|
6
4
|
subject(:splitter) { described_class.new }
|
7
5
|
|
@@ -10,11 +8,16 @@ RSpec.describe RSpeed::Splitter, '#append' do
|
|
10
8
|
|
11
9
|
expect(splitter.get('rspeed_tmp')).to eq [
|
12
10
|
'{"file":"2_spec.rb","time":2.0}',
|
13
|
-
'{"file":"1_spec.rb","time":1.0}'
|
11
|
+
'{"file":"1_spec.rb","time":1.0}',
|
14
12
|
]
|
15
13
|
end
|
16
14
|
|
17
15
|
context 'when files is not given' do
|
16
|
+
before do
|
17
|
+
truncate_file
|
18
|
+
populate_csv_file
|
19
|
+
end
|
20
|
+
|
18
21
|
it 'read csv and append file and time on rspeed key' do
|
19
22
|
splitter.append
|
20
23
|
|
@@ -1,29 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
3
|
RSpec.describe RSpeed::Splitter, '#diff' do
|
6
|
-
subject(:splitter) { described_class.new }
|
4
|
+
subject(:splitter) { described_class.new(specs_path: './spec/fixtures/*_spec.rb') }
|
7
5
|
|
8
6
|
let!(:redis) { redis_object }
|
9
7
|
|
10
8
|
before do
|
11
|
-
redis.lpush 'rspeed', { file: '1_spec.rb', time: 1 }.to_json
|
12
|
-
redis.lpush 'rspeed', { file: '
|
13
|
-
redis.lpush 'rspeed', { file: '
|
9
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/1_spec.rb:4', time: '1.4' }.to_json
|
10
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/1_spec.rb:6', time: '1.6' }.to_json
|
11
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/1_spec.rb:8', time: '1.8' }.to_json
|
12
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/2_spec.rb:4', time: '2.4' }.to_json
|
13
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/2_spec.rb:666', time: '6' }.to_json
|
14
|
+
redis.lpush 'rspeed', { file: './spec/fixtures/x_spec.rb:1', time: 3 }.to_json
|
14
15
|
|
15
|
-
|
16
|
-
2_spec.rb
|
17
|
-
3_spec.rb
|
18
|
-
4_spec.rb
|
19
|
-
]
|
16
|
+
File.open('spec/fixtures/new_spec.rb', 'a') { |file| file.write('it') }
|
20
17
|
end
|
21
18
|
|
19
|
+
after { delete_file('spec/fixtures/new_spec.rb') }
|
20
|
+
|
22
21
|
it 'removes removed specs and adds new spec and keeps keeped specs based on rspeed key values' do
|
23
22
|
expect(splitter.diff).to eq [
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
{ file: './spec/fixtures/2_spec.rb:4', time: '2.4' },
|
24
|
+
{ file: './spec/fixtures/1_spec.rb:8', time: '1.8' },
|
25
|
+
{ file: './spec/fixtures/1_spec.rb:6', time: '1.6' },
|
26
|
+
{ file: './spec/fixtures/1_spec.rb:4', time: '1.4' },
|
27
|
+
{ file: './spec/fixtures/new_spec.rb:1', time: 0 },
|
27
28
|
]
|
28
29
|
end
|
29
30
|
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
3
|
RSpec.describe RSpeed::Splitter, '.first_pipe?' do
|
6
4
|
subject(:splitter) { described_class.new }
|
7
5
|
|
8
6
|
context 'when pipe env is 1' do
|
9
|
-
before { allow(
|
7
|
+
before { allow(RSpeed::Env).to receive(:pipe).and_return 1 }
|
10
8
|
|
11
9
|
it { expect(splitter.first_pipe?).to eq true }
|
12
10
|
end
|
13
11
|
|
14
12
|
context 'when pipe env is not 1' do
|
15
|
-
before { allow(
|
13
|
+
before { allow(RSpeed::Env).to receive(:pipe).and_return 2 }
|
16
14
|
|
17
15
|
it { expect(splitter.first_pipe?).to eq false }
|
18
16
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rails_helper'
|
4
|
-
|
5
3
|
RSpec.describe RSpeed::Splitter, '#get' do
|
6
4
|
subject(:splitter) { described_class.new }
|
7
5
|
|
@@ -18,14 +16,14 @@ RSpec.describe RSpeed::Splitter, '#get' do
|
|
18
16
|
{
|
19
17
|
'files' => [[1, '1_spec.rb'], [2, '2_spec.rb']],
|
20
18
|
'number' => 0,
|
21
|
-
'total' => 3
|
19
|
+
'total' => 3,
|
22
20
|
},
|
23
21
|
|
24
22
|
{
|
25
23
|
'files' => [[3, '3_spec.rb']],
|
26
24
|
'number' => 1,
|
27
|
-
'total' => 3
|
28
|
-
}
|
25
|
+
'total' => 3,
|
26
|
+
},
|
29
27
|
]
|
30
28
|
end
|
31
29
|
end
|
@@ -40,8 +38,8 @@ RSpec.describe RSpeed::Splitter, '#get' do
|
|
40
38
|
{
|
41
39
|
'files' => [[1, '1_spec.rb'], [2, '2_spec.rb']],
|
42
40
|
'number' => 0,
|
43
|
-
'total' => 3
|
44
|
-
}
|
41
|
+
'total' => 3,
|
42
|
+
},
|
45
43
|
]
|
46
44
|
end
|
47
45
|
end
|
@@ -55,7 +53,7 @@ RSpec.describe RSpeed::Splitter, '#get' do
|
|
55
53
|
it 'executes the right fetch method' do
|
56
54
|
expect(splitter.get('rspeed')).to eq [
|
57
55
|
'{"file":"2_spec.rb","time":2}',
|
58
|
-
'{"file":"1_spec.rb","time":1}'
|
56
|
+
'{"file":"1_spec.rb","time":1}',
|
59
57
|
]
|
60
58
|
end
|
61
59
|
end
|
@@ -69,7 +67,7 @@ RSpec.describe RSpeed::Splitter, '#get' do
|
|
69
67
|
it 'executes the right fetch method' do
|
70
68
|
expect(splitter.get('rspeed_tmp')).to eq [
|
71
69
|
'{"file":"2_spec.rb","time":2}',
|
72
|
-
'{"file":"1_spec.rb","time":1}'
|
70
|
+
'{"file":"1_spec.rb","time":1}',
|
73
71
|
]
|
74
72
|
end
|
75
73
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe RSpeed::Splitter, '#need_warm?' do
|
4
|
+
subject(:splitter) { described_class.new }
|
5
|
+
|
6
|
+
context 'when has no result' do
|
7
|
+
before { allow(RSpeed::Redis).to receive(:result?).and_return(false) }
|
8
|
+
|
9
|
+
context 'when is not the first pipe' do
|
10
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(false) }
|
11
|
+
|
12
|
+
it { expect(splitter.need_warm?).to be(false) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when is the first pipe' do
|
16
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(true) }
|
17
|
+
|
18
|
+
it { expect(splitter.need_warm?).to be(true) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when has result' do
|
23
|
+
before { allow(RSpeed::Redis).to receive(:result?).and_return(true) }
|
24
|
+
|
25
|
+
context 'when is not the first pipe' do
|
26
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(false) }
|
27
|
+
|
28
|
+
it { expect(splitter.need_warm?).to be(false) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when is the first pipe' do
|
32
|
+
before { allow(splitter).to receive(:first_pipe?).and_return(true) }
|
33
|
+
|
34
|
+
it { expect(splitter.need_warm?).to be(false) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|