rspeed 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +11 -7
  4. data/lib/generators/rspeed/install_generator.rb +1 -1
  5. data/lib/rspeed.rb +8 -6
  6. data/lib/rspeed/env.rb +43 -0
  7. data/lib/rspeed/extension.rb +3 -2
  8. data/lib/rspeed/observer.rb +17 -3
  9. data/lib/rspeed/redis.rb +55 -0
  10. data/lib/rspeed/runner.rb +3 -18
  11. data/lib/rspeed/splitter.rb +29 -52
  12. data/lib/rspeed/variable.rb +31 -0
  13. data/lib/rspeed/version.rb +1 -1
  14. data/spec/common_helper.rb +10 -0
  15. data/spec/fixtures/empty.rb +4 -0
  16. data/spec/models/rspeed/env/db_spec.rb +17 -0
  17. data/spec/models/rspeed/env/host_spec.rb +17 -0
  18. data/spec/models/rspeed/env/name_spec.rb +17 -0
  19. data/spec/models/rspeed/env/pipe_spec.rb +19 -0
  20. data/spec/models/rspeed/env/pipes_spec.rb +41 -0
  21. data/spec/models/rspeed/env/port_spec.rb +17 -0
  22. data/spec/models/rspeed/env/result_key_spec.rb +19 -0
  23. data/spec/models/rspeed/env/rspeed_spec.rb +43 -0
  24. data/spec/models/rspeed/env/tmp_spec.rb +19 -0
  25. data/spec/models/rspeed/observer/after_spec.rb +0 -2
  26. data/spec/models/rspeed/observer/after_suite_spec.rb +46 -0
  27. data/spec/models/rspeed/observer/before_spec.rb +0 -2
  28. data/spec/models/rspeed/observer/before_suite_spec.rb +24 -2
  29. data/spec/models/rspeed/redis/clean_pipes_flag_spec.rb +14 -0
  30. data/spec/models/rspeed/redis/client_spec.rb +7 -0
  31. data/spec/models/rspeed/redis/destroy_spec.rb +29 -0
  32. data/spec/models/rspeed/redis/get_spec.rb +9 -0
  33. data/spec/models/rspeed/redis/keys_spec.rb +29 -0
  34. data/spec/models/rspeed/redis/result_spec.rb +13 -0
  35. data/spec/models/rspeed/redis/set_spec.rb +9 -0
  36. data/spec/models/rspeed/redis/specs_finished_spec.rb +19 -0
  37. data/spec/models/rspeed/redis/specs_initiated_spec.rb +13 -0
  38. data/spec/models/rspeed/runner/run_spec.rb +30 -0
  39. data/spec/models/rspeed/splitter/actual_examples_spec.rb +6 -2
  40. data/spec/models/rspeed/splitter/append_spec.rb +1 -3
  41. data/spec/models/rspeed/splitter/diff_spec.rb +1 -3
  42. data/spec/models/rspeed/splitter/first_pipe_spec.rb +2 -4
  43. data/spec/models/rspeed/splitter/get_spec.rb +7 -9
  44. data/spec/models/rspeed/splitter/pipe_files_spec.rb +26 -0
  45. data/spec/models/rspeed/splitter/redundant_run_spec.rb +45 -0
  46. data/spec/models/rspeed/splitter/rename_spec.rb +3 -5
  47. data/spec/models/rspeed/splitter/split_spec.rb +70 -34
  48. data/spec/models/rspeed/variable/append_name_spec.rb +19 -0
  49. data/spec/models/rspeed/variable/csv_spec.rb +5 -0
  50. data/spec/models/rspeed/variable/default_partner_spec.rb +5 -0
  51. data/spec/models/rspeed/variable/key_spec.rb +15 -0
  52. data/spec/models/rspeed/variable/pipe_name_spec.rb +15 -0
  53. data/spec/models/rspeed/variable/pipes_pattern_spec.rb +5 -0
  54. data/spec/models/rspeed/variable/result_spec.rb +19 -0
  55. data/spec/models/rspeed/variable/tmp_spec.rb +15 -0
  56. data/spec/{rails_helper.rb → spec_helper.rb} +2 -22
  57. data/spec/support/common.rb +13 -0
  58. data/spec/support/coverage.rb +14 -0
  59. data/spec/support/env_mock.rb +3 -0
  60. data/spec/support/fakeredis.rb +3 -0
  61. metadata +137 -20
  62. data/spec/models/rspeed/splitter/destroy_spec.rb +0 -33
  63. data/spec/models/rspeed/splitter/keys_spec.rb +0 -33
  64. data/spec/models/rspeed/splitter/last_pipe_spec.rb +0 -21
  65. data/spec/models/rspeed/splitter/pipe_spec.rb +0 -21
  66. data/spec/models/rspeed/splitter/pipes_spec.rb +0 -27
  67. data/spec/models/rspeed/splitter/result_spec.rb +0 -19
  68. data/spec/models/rspeed/splitter/save_spec.rb +0 -57
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '.keys' do
6
- subject(:splitter) { described_class.new }
7
-
8
- let!(:redis) { redis_object }
9
-
10
- context 'with default config' do
11
- before do
12
- redis.set 'rspeed_1', 'value_1'
13
- redis.set 'rspeed_2', 'value_2'
14
- redis.set 'rspeed_3', 'value_3'
15
- end
16
-
17
- it 'shows keys' do
18
- expect(splitter.keys).to eq %w[rspeed_1 rspeed_2 rspeed_3]
19
- end
20
- end
21
-
22
- context 'with custom key' do
23
- before do
24
- redis.set 'custom_key_1', 'value_1'
25
- redis.set 'custom_key_2', 'value_2'
26
- redis.set 'custom_key_3', 'value_3'
27
- end
28
-
29
- it 'shows keys' do
30
- expect(splitter.keys('custom_key_*')).to eq %w[custom_key_1 custom_key_2 custom_key_3]
31
- end
32
- end
33
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '.last_pipe?' do
6
- subject(:splitter) { described_class.new }
7
-
8
- before { allow(splitter).to receive(:pipes).and_return 3 }
9
-
10
- context 'when pipe env is equal pipes env' do
11
- before { allow(splitter).to receive(:pipe).and_return 3 }
12
-
13
- it { expect(splitter.last_pipe?).to eq true }
14
- end
15
-
16
- context 'when pipe env not equal pipes env' do
17
- before { allow(splitter).to receive(:pipe).and_return 2 }
18
-
19
- it { expect(splitter.last_pipe?).to eq false }
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '#pipe' do
6
- subject(:splitter) { described_class.new }
7
-
8
- context 'when pipe env is given' do
9
- before { ENV['RSPEED_PIPE'] = '2' }
10
-
11
- it 'returns the number of the current pipe' do
12
- expect(splitter.pipe).to eq 2
13
- end
14
- end
15
-
16
- context 'when pipe env is not given' do
17
- it 'returns 1' do
18
- expect(splitter.pipe).to eq 1
19
- end
20
- end
21
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '#pipes' do
6
- subject(:splitter) { described_class.new }
7
-
8
- context 'when has no result' do
9
- before { allow(splitter).to receive(:result?).and_return(false) }
10
-
11
- it 'the number of pipes is adjusted to one' do
12
- expect(splitter.pipes).to eq 1
13
- end
14
- end
15
-
16
- context 'when has result' do
17
- before do
18
- allow(splitter).to receive(:result?).and_return(true)
19
-
20
- ENV['RSPEED_PIPES'] = '2'
21
- end
22
-
23
- it 'is used the given value on env' do
24
- expect(splitter.pipes).to eq 2
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '#result?' do
6
- subject(:splitter) { described_class.new }
7
-
8
- context 'when has no key rspeed on redis' do
9
- it { expect(splitter.result?).to eq false }
10
- end
11
-
12
- context 'when has no key rspeed on redis' do
13
- let!(:redis) { redis_object }
14
-
15
- before { redis.set 'rspeed', { files: [[1, '1_spec.rb']], number: 0, total: 1 }.to_json }
16
-
17
- it { expect(splitter.result?).to eq true }
18
- end
19
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe RSpeed::Splitter, '.save' do
6
- subject(:splitter) { described_class.new }
7
-
8
- let!(:redis) { redis_object }
9
-
10
- before do
11
- allow(splitter).to receive(:pipes).and_return(3)
12
-
13
- allow(splitter).to receive(:diff).and_return([
14
- { file: "./spec/0_2_spec.rb", time: '0.2' },
15
- { file: "./spec/0_3_spec.rb", time: '0.3' },
16
- { file: "./spec/0_4_spec.rb", time: '0.4' },
17
- { file: "./spec/0_7_spec.rb", time: '0.7' },
18
- { file: "./spec/1_1_spec.rb", time: '1.1' },
19
- { file: "./spec/1_5_spec.rb", time: '1.5' },
20
- { file: "./spec/2_0_spec.rb", time: '2.0' },
21
- ])
22
- end
23
-
24
- it 'saves the data on redis' do
25
- splitter.save
26
-
27
- expect(redis.keys('*')).to eq %w[rspeed_1 rspeed_2 rspeed_3]
28
-
29
- expect(JSON.parse(redis.get('rspeed_1'), symbolize_names: true)).to eq(
30
- files: [{ file: './spec/2_0_spec.rb', time: 2.0 }],
31
- number: 1,
32
- total: 2.0
33
- )
34
-
35
- expect(JSON.parse(redis.get('rspeed_2'), symbolize_names: true)).to eq(
36
- files: [
37
- { file: './spec/1_5_spec.rb', time: 1.5 },
38
- { file: './spec/0_4_spec.rb', time: 0.4 },
39
- { file: './spec/0_2_spec.rb', time: 0.2 }
40
- ],
41
-
42
- number: 2,
43
- total: 1.5 + 0.4 + 0.2
44
- )
45
-
46
- expect(JSON.parse(redis.get('rspeed_3'), symbolize_names: true)).to eq(
47
- files: [
48
- { file: './spec/1_1_spec.rb', time: 1.1 },
49
- { file: './spec/0_7_spec.rb', time: 0.7 },
50
- { file: './spec/0_3_spec.rb', time: 0.3 }
51
- ],
52
-
53
- number: 3,
54
- total: 1.1 + 0.7 + 0.3
55
- )
56
- end
57
- end