rspeed 0.5.1 → 0.5.2

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
  SHA256:
3
- metadata.gz: de6e5d6c3ca630b15b835939ec2b01adbeec526480efde16052c294f297457af
4
- data.tar.gz: 4c4d1efdf65c9f4c01106f1fe109d8ffb2160e40b6f90813b4bdc813061613dc
3
+ metadata.gz: 4a58e610b2982e8a8f81783f5704f0a136c971aa6df1a446cf32ce7a53485120
4
+ data.tar.gz: 41c88139eff91637c52cda59b1239ca1833aa0db886677d0a33c51564d500a19
5
5
  SHA512:
6
- metadata.gz: 5ab45f421853bee217c88cfad0efd5d2bd16b9968b17b7676593b4ae0a2e708ac6b646f40845b8f186adfc000c505cef4e95f77c7c8273e6964203b0de22420a
7
- data.tar.gz: 7e32c34c76fcdaff18e2aa2726c232d42c32fb4e3fc55b452f0d9b62f2dff0e5f458acd4c3dbacae75b5ca0c330e4b2792618179675c11adcf8aa566d13106c9
6
+ metadata.gz: 67b9c9d9334b315b9392bf7a52965bc1884ab67c96345abf3f037b185010b4de24f9b895cc306567f9cf07737786d7f58edc4ab14f0e45a26acef8acd525ed2f
7
+ data.tar.gz: e2771f90d265bbfc5ea3273c82aa467dee40b3f5cbfc40ac0c7501da4577664c28bd11b491a1568907775584490a36e3c4d5c1935cc375aca27ff8713e9b0b00
data/CHANGELOG.md CHANGED
@@ -1,6 +1,7 @@
1
1
  ## master
2
2
 
3
- - None;
3
+ - CSV dependency dropped;
4
+ - Drops tmp key in favor of profile keys fetch;
4
5
 
5
6
  ## v0.5.1
6
7
 
data/README.md CHANGED
@@ -30,7 +30,6 @@ rake rspeed:install
30
30
  - `RSPEED_PIPE`: Current pipe
31
31
  - `RSPEED_PIPES`: Quantity of pipes
32
32
  - `RSPEED_RESULT_KEY`: The key that keeps the final result of all pipes
33
- - `RSPEED_TMP_KEY`: The temporary key that keeps the partial result of the pipes
34
33
  - `RSPEED`: Enables RSpeed
35
34
 
36
35
  ```sh
data/lib/rspeed.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpeed
4
- require 'csv'
5
-
6
4
  require 'rspeed/env'
7
5
  require 'rspeed/extension'
8
6
  require 'rspeed/logger'
data/lib/rspeed/env.rb CHANGED
@@ -35,9 +35,5 @@ module RSpeed
35
35
  def rspeed
36
36
  ENV['RSPEED'] == 'true'
37
37
  end
38
-
39
- def tmp_key
40
- ENV.fetch('RESPEED_TMP_KEY', RSpeed::Variable.tmp)
41
- end
42
38
  end
43
39
  end
@@ -9,21 +9,21 @@ module RSpeed
9
9
  line_number = example.metadata[:line_number]
10
10
  spent_time = example.clock.now - example.metadata[:start_at]
11
11
 
12
- File.open(RSpeed::Variable::CSV, 'a') do |file|
13
- file.write("#{spent_time},#{file_path}:#{line_number}\n")
14
- end
12
+ json = { file: "#{file_path}:#{line_number}", time: spent_time }.to_json
13
+
14
+ RSpeed::Redis.client.lpush(RSpeed::Variable.profile, json)
15
15
  end
16
16
 
17
17
  def after_suite(splitter = ::RSpeed::Splitter.new)
18
18
  RSpeed::Redis.set(RSpeed::Variable.pipe_name, true)
19
19
 
20
- splitter.append if splitter.append?
21
-
22
20
  return unless RSpeed::Redis.specs_finished?
23
21
 
24
22
  splitter.rename
25
23
 
26
24
  RSpeed::Redis.clean
25
+
26
+ RSpeed::Logger.log('RSpeed finished.')
27
27
  end
28
28
 
29
29
  def before(example)
@@ -31,13 +31,14 @@ module RSpeed
31
31
  end
32
32
 
33
33
  def before_suite
34
- truncate_csv_file
35
-
36
- RSpeed::Redis.destroy(RSpeed::Variable.tmp) unless RSpeed::Redis.specs_initiated?
34
+ clean_profile
37
35
  end
38
36
 
39
- def truncate_csv_file
40
- File.open(RSpeed::Variable::CSV, 'w') { |file| file.truncate(0) }
37
+ def clean_profile
38
+ RSpeed::Logger.log('[RSpeed::Observer#clean_profile] Cleanning current flag and profile.')
39
+
40
+ RSpeed::Redis.destroy(RSpeed::Variable.pipe_name)
41
+ RSpeed::Redis.destroy(RSpeed::Variable.profile)
41
42
  end
42
43
  end
43
44
  end
data/lib/rspeed/redis.rb CHANGED
@@ -7,7 +7,10 @@ module RSpeed
7
7
  module_function
8
8
 
9
9
  def clean
10
+ RSpeed::Logger.log('[RSpeed::Redis#clean] Cleaning pipes and profiles.')
11
+
10
12
  destroy(RSpeed::Variable::PIPES_PATTERN)
13
+ destroy(RSpeed::Variable::PROFILE_PATTERN)
11
14
  end
12
15
 
13
16
  def client
@@ -15,6 +18,8 @@ module RSpeed
15
18
  end
16
19
 
17
20
  def destroy(pattern = RSpeed::Variable::DEFAULT_PATTERN)
21
+ RSpeed::Logger.log(%([RSpeed::Redis#destroy] Destroying pattern "#{pattern}".))
22
+
18
23
  keys(pattern).each { |key| client.del(key) }
19
24
  end
20
25
 
@@ -45,11 +50,15 @@ module RSpeed
45
50
  end
46
51
 
47
52
  def specs_finished?
48
- RSpeed::Redis.keys(RSpeed::Variable::PIPES_PATTERN).size == RSpeed::Env.pipes
53
+ (RSpeed::Redis.keys(RSpeed::Variable::PIPES_PATTERN).size == RSpeed::Env.pipes).tap do |boo|
54
+ RSpeed::Logger.log("[RSpeed::Redis#specs_finished?] Specs #{boo ? 'finished.' : 'not fineshed yet.'}")
55
+ end
49
56
  end
50
57
 
51
58
  def specs_initiated?
52
- RSpeed::Redis.keys(RSpeed::Variable::PIPES_PATTERN).any?
59
+ RSpeed::Redis.keys(RSpeed::Variable::PIPES_PATTERN).any?.tap do |boo|
60
+ RSpeed::Logger.log("[RSpeed::Redis#specs_initiated?] Specs #{boo ? 'initialized.' : 'not initialized yet.'}")
61
+ end
53
62
  end
54
63
  end
55
64
  end
data/lib/rspeed/runner.rb CHANGED
@@ -5,7 +5,9 @@ module RSpeed
5
5
  module_function
6
6
 
7
7
  def run(shell, splitter: ::RSpeed::Splitter.new)
8
- return shell.call(['bundle exec rspec', splitter.pipe_files].compact.join(' ')) if splitter.need_warm?
8
+ if RSpeed::Redis.result? || splitter.first_pipe?
9
+ return shell.call(['bundle exec rspec', splitter.pipe_files].compact.join(' '))
10
+ end
9
11
 
10
12
  RSpeed::Logger.log("Pipe #{RSpeed::Env.pipe} skipped. Only Pipe 1 can warm.")
11
13
 
@@ -29,10 +29,8 @@ module RSpeed
29
29
  RSpeed::Redis.result? || first_pipe?
30
30
  end
31
31
 
32
- def append(files = CSV.read(RSpeed::Variable::CSV))
33
- files.each do |time, file|
34
- redis.lpush(RSpeed::Env.tmp_key, { file: file, time: time.to_f }.to_json)
35
- end
32
+ def append(items:, key:)
33
+ items.each { |item| redis.rpush(key, item) }
36
34
  end
37
35
 
38
36
  def diff
@@ -50,7 +48,7 @@ module RSpeed
50
48
 
51
49
  def get(pattern)
52
50
  @get ||= begin
53
- return redis.lrange(pattern, 0, -1) if [RSpeed::Variable.result, RSpeed::Variable.tmp].include?(pattern)
51
+ return redis.lrange(pattern, 0, -1) if [RSpeed::Variable.result].include?(pattern)
54
52
 
55
53
  RSpeed::Redis.keys(pattern).map { |key| ::JSON.parse(redis.get(key)) }
56
54
  end
@@ -67,7 +65,14 @@ module RSpeed
67
65
  end
68
66
 
69
67
  def rename
70
- redis.rename(RSpeed::Env.tmp_key, RSpeed::Env.result_key)
68
+ RSpeed::Logger.log('[RSpeed::Splitter#consolidate] Consolidating profiles.')
69
+
70
+ RSpeed::Redis.destroy(RSpeed::Env.result_key)
71
+
72
+ append(
73
+ items: RSpeed::Redis.client.keys('rspeed_profile_*').map { |key| redis.lrange(key, 0, -1) },
74
+ key: RSpeed::Env.result_key
75
+ )
71
76
  end
72
77
 
73
78
  def split(data = diff)
@@ -4,9 +4,9 @@ module RSpeed
4
4
  module Variable
5
5
  module_function
6
6
 
7
- CSV = 'rspeed.csv'
8
7
  DEFAULT_PATTERN = 'rspeed_*'
9
8
  PIPES_PATTERN = 'rspeed_pipe_*'
9
+ PROFILE_PATTERN = 'rspeed_profile_*'
10
10
 
11
11
  def append_name(value, suffix = nil)
12
12
  [value, RSpeed::Env.name, suffix].compact.join('_')
@@ -20,12 +20,12 @@ module RSpeed
20
20
  append_name('rspeed')
21
21
  end
22
22
 
23
- def tmp
24
- append_name('rspeed_tmp')
25
- end
26
-
27
23
  def pipe_name
28
24
  append_name('rspeed_pipe', RSpeed::Env.pipe)
29
25
  end
26
+
27
+ def profile
28
+ append_name('rspeed_profile', RSpeed::Env.pipe)
29
+ end
30
30
  end
31
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpeed
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.2'
5
5
  end
@@ -6,11 +6,13 @@ RSpec.describe RSpeed::Observer, '.after' do
6
6
  let!(:metadata) { { file_path: 'file_path', line_number: 7, start_at: now - 1 } }
7
7
  let!(:example) { instance_double(RSpec::Core::Example, clock: clock, metadata: metadata) }
8
8
 
9
- before { truncate_file }
9
+ before { truncate_profiles }
10
10
 
11
- it 'appends the time of example on csv file' do
11
+ it 'appends the file and time on pipe profile key' do
12
12
  described_class.after(example)
13
13
 
14
- expect(File.open('rspeed.csv').read).to eq "1.0,file_path:7\n"
14
+ expect(RSpeed::Redis.client.lrange(RSpeed::Variable.profile, 0, -1)).to eq [
15
+ { file: 'file_path:7', time: 1.0 }.to_json,
16
+ ]
15
17
  end
16
18
  end
@@ -8,26 +8,13 @@ RSpec.describe RSpeed::Observer, '.after_suite' do
8
8
  allow(splitter).to receive(:append)
9
9
  end
10
10
 
11
- context 'when append? returns true' do
12
- before do
13
- allow(splitter).to receive(:append?).and_return(true)
14
- allow(splitter).to receive(:rename)
15
- end
16
-
17
- it 'appends the time result on tmp key' do
18
- described_class.after_suite
19
-
20
- expect(splitter).to have_received(:append)
21
- end
22
- end
23
-
24
11
  context 'when append? returns false' do
25
12
  before do
26
13
  allow(splitter).to receive(:append?).and_return(false)
27
14
  allow(splitter).to receive(:rename)
28
15
  end
29
16
 
30
- it 'does not append the time result on tmp key' do
17
+ it 'does not append the time result' do
31
18
  described_class.after_suite
32
19
 
33
20
  expect(splitter).not_to have_received(:append)
@@ -55,7 +42,7 @@ RSpec.describe RSpeed::Observer, '.after_suite' do
55
42
  allow(RSpeed::Redis).to receive(:clean)
56
43
  end
57
44
 
58
- it 'renames the tmp data to the permanent key result' do
45
+ it 'consolidates profiles' do
59
46
  described_class.after_suite
60
47
 
61
48
  expect(splitter).to have_received(:rename)
@@ -1,37 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe RSpeed::Observer, '.before_suite' do
4
- before { truncate_file }
4
+ let!(:redis) { redis_object }
5
5
 
6
- it 'cleans the csv file' do
7
- File.open('rspeed.csv', 'a') { |file| file.write('content') }
6
+ before { truncate_profiles }
7
+ after { truncate_profiles }
8
8
 
9
- described_class.before_suite
10
-
11
- expect(File.open('rspeed.csv').read).to eq ''
12
- end
13
-
14
- context 'when specs are not initiated yet' do
15
- before { allow(RSpeed::Redis).to receive(:specs_initiated?).and_return(false) }
9
+ it 'cleans only the current pipe profile' do
10
+ redis.lpush('rspeed_profile_1', { file: '1_spec.rb', time: 1 }.to_json)
11
+ redis.lpush('rspeed_profile_2', { file: '2_spec.rb', time: 2 }.to_json)
16
12
 
17
- it 'destroyes the tmp result key' do
18
- RSpeed::Redis.client.lpush(RSpeed::Env.tmp_key, { file: 'file', time: 1.0 }.to_json)
19
-
20
- described_class.before_suite
13
+ described_class.before_suite
21
14
 
22
- expect(RSpeed::Splitter.new.get(RSpeed::Variable.tmp)).to eq([])
23
- end
15
+ expect(redis.keys).to eq ['rspeed_profile_2']
24
16
  end
25
17
 
26
- context 'when specs are already initiated' do
27
- before { allow(RSpeed::Redis).to receive(:specs_initiated?).and_return(true) }
18
+ it 'cleans the pipe flag' do
19
+ redis.set('rspeed_pipe_1', true)
20
+ redis.set('rspeed_pipe_2', true)
28
21
 
29
- it 'does not destroy the tmp result key' do
30
- RSpeed::Redis.client.lpush(RSpeed::Env.tmp_key, { file: 'file', time: 1.0 }.to_json)
31
-
32
- described_class.before_suite
22
+ described_class.before_suite
33
23
 
34
- expect(RSpeed::Splitter.new.get(RSpeed::Variable.tmp)).to eq(['{"file":"file","time":1.0}'])
35
- end
24
+ expect(redis.keys).to eq ['rspeed_pipe_2']
36
25
  end
37
26
  end
@@ -9,4 +9,12 @@ RSpec.describe RSpeed::Redis, '.clean' do
9
9
 
10
10
  expect(described_class.keys('*')).to eq([])
11
11
  end
12
+
13
+ it 'destroys the pipe profiles' do
14
+ described_class.set('rspeed_profile_1', true)
15
+
16
+ described_class.clean
17
+
18
+ expect(described_class.keys('*')).to eq([])
19
+ end
12
20
  end
@@ -7,41 +7,71 @@ RSpec.describe RSpeed::Runner, '#run' do
7
7
  before do
8
8
  allow(shell).to receive(:call)
9
9
  allow(RSpeed::Splitter).to receive(:new).and_return(splitter)
10
- allow(RSpeed::Observer).to receive(:after_suite)
11
10
  end
12
11
 
13
- context 'when does not need warm' do
14
- before { allow(splitter).to receive(:need_warm?).and_return(false) }
12
+ context 'when has result' do
13
+ before { allow(RSpeed::Redis).to receive(:result?).and_return(true) }
15
14
 
16
- it 'does not run the specs' do
17
- described_class.run(shell)
15
+ context 'when is the first pipe' do
16
+ before do
17
+ allow(splitter).to receive(:first_pipe?).and_return(true)
18
+ allow(splitter).to receive(:pipe_files).and_return('spec_1.rb spec_2.rb')
19
+ end
18
20
 
19
- expect(shell).not_to have_received(:call)
21
+ it 'runs the pipe specs' do
22
+ described_class.run(shell)
23
+
24
+ expect(shell).to have_received(:call).with('bundle exec rspec spec_1.rb spec_2.rb')
25
+ end
20
26
  end
21
27
 
22
- it 'executes the after suite to complete the current pipe' do
23
- described_class.run(shell)
28
+ context 'when is not the first pipe' do
29
+ before do
30
+ allow(splitter).to receive(:first_pipe?).and_return(false)
31
+ allow(splitter).to receive(:pipe_files).and_return('spec_1.rb spec_2.rb')
32
+ end
33
+
34
+ it 'runs the pipe specs' do
35
+ described_class.run(shell)
24
36
 
25
- expect(RSpeed::Observer).to have_received(:after_suite)
37
+ expect(shell).to have_received(:call).with('bundle exec rspec spec_1.rb spec_2.rb')
38
+ end
26
39
  end
27
40
  end
28
41
 
29
- context 'when need warm' do
42
+ context 'when has no result' do
30
43
  before do
31
- allow(splitter).to receive(:need_warm?).and_return(true)
44
+ allow(splitter).to receive(:first_pipe?).and_return(false)
32
45
  allow(splitter).to receive(:pipe_files).and_return('spec_1.rb spec_2.rb')
33
46
  end
34
47
 
35
- it 'run the pipe specs' do
36
- described_class.run(shell)
48
+ context 'when is the first pipe' do
49
+ before { allow(splitter).to receive(:first_pipe?).and_return(true) }
50
+
51
+ it 'runs the pipe specs' do
52
+ described_class.run(shell)
37
53
 
38
- expect(shell).to have_received(:call).with('bundle exec rspec spec_1.rb spec_2.rb')
54
+ expect(shell).to have_received(:call).with('bundle exec rspec spec_1.rb spec_2.rb')
55
+ end
39
56
  end
40
57
 
41
- it 'does not execute the after suite to complete the current pipe' do
42
- described_class.run(shell)
58
+ context 'when is not the first pipe' do
59
+ before do
60
+ allow(splitter).to receive(:first_pipe?).and_return(false)
61
+ allow(RSpeed::Observer).to receive(:after_suite)
62
+ end
63
+
64
+ it 'does not run the pipe specs' do
65
+ described_class.run(shell)
66
+
67
+ expect(shell).not_to have_received(:call)
68
+ end
69
+
70
+ it 'executes the after suite callback' do
71
+ described_class.run(shell)
43
72
 
44
- expect(RSpeed::Observer).not_to have_received(:after_suite)
73
+ expect(RSpeed::Observer).to have_received(:after_suite)
74
+ end
45
75
  end
46
76
  end
47
77
  end
@@ -3,33 +3,17 @@
3
3
  RSpec.describe RSpeed::Splitter, '#append' do
4
4
  subject(:splitter) { described_class.new }
5
5
 
6
+ let!(:redis) { redis_object }
7
+
6
8
  it 'appends file and time on rspeed key' do
7
- splitter.append [[1, '1_spec.rb'], [2, '2_spec.rb']]
9
+ splitter.append(
10
+ items: [{ file: '1_spec.rb', time: 1 }.to_json, { file: '2_spec.rb', time: 2 }.to_json],
11
+ key: 'rspeed'
12
+ )
8
13
 
9
- expect(splitter.get('rspeed_tmp')).to eq [
10
- '{"file":"2_spec.rb","time":2.0}',
11
- '{"file":"1_spec.rb","time":1.0}',
14
+ expect(redis.lrange('rspeed', 0, -1)).to eq [
15
+ '{"file":"1_spec.rb","time":1}',
16
+ '{"file":"2_spec.rb","time":2}',
12
17
  ]
13
18
  end
14
-
15
- context 'when files is not given' do
16
- before do
17
- truncate_file
18
- populate_csv_file
19
- end
20
-
21
- it 'read csv and append file and time on rspeed key' do
22
- splitter.append
23
-
24
- expect(splitter.get('rspeed_tmp')).to eq [
25
- '{"file":"./spec/0_2_spec.rb","time":0.2}',
26
- '{"file":"./spec/0_3_spec.rb","time":0.3}',
27
- '{"file":"./spec/0_4_spec.rb","time":0.4}',
28
- '{"file":"./spec/0_7_spec.rb","time":0.7}',
29
- '{"file":"./spec/1_1_spec.rb","time":1.1}',
30
- '{"file":"./spec/1_5_spec.rb","time":1.5}',
31
- '{"file":"./spec/2_0_spec.rb","time":2.0}',
32
- ]
33
- end
34
- end
35
19
  end
@@ -57,18 +57,4 @@ RSpec.describe RSpeed::Splitter, '#get' do
57
57
  ]
58
58
  end
59
59
  end
60
-
61
- context 'when pattern is rspeed_tmp' do
62
- before do
63
- redis.lpush 'rspeed_tmp', { file: '1_spec.rb', time: 1 }.to_json
64
- redis.lpush 'rspeed_tmp', { file: '2_spec.rb', time: 2 }.to_json
65
- end
66
-
67
- it 'executes the right fetch method' do
68
- expect(splitter.get('rspeed_tmp')).to eq [
69
- '{"file":"2_spec.rb","time":2}',
70
- '{"file":"1_spec.rb","time":1}',
71
- ]
72
- end
73
- end
74
60
  end
@@ -5,12 +5,21 @@ RSpec.describe RSpeed::Splitter, '#rename' do
5
5
 
6
6
  let!(:redis) { redis_object }
7
7
 
8
- before { redis.lpush('rspeed_tmp', { file: '1_spec.rb', time: 1.0 }.to_json) }
8
+ before do
9
+ redis.lpush('rspeed', 'rspeed_content')
9
10
 
10
- it 'renames the key' do
11
+ redis.lpush('rspeed_profile_1', { file: '1_spec.rb', time: 1.0 }.to_json)
12
+ redis.lpush('rspeed_profile_2', { file: '2_spec.rb', time: 2.0 }.to_json)
13
+ redis.lpush('rspeed_profile_3', { file: '3_spec.rb', time: 3.0 }.to_json)
14
+ end
15
+
16
+ it 'copies profiles to the result key cleanning the previous result' do
11
17
  splitter.rename
12
18
 
13
- expect(redis.lrange('rspeed_tmp', 0, -1)).to eq([])
14
- expect(redis.lrange('rspeed', 0, -1)).to eq(['{"file":"1_spec.rb","time":1.0}'])
19
+ expect(redis.lrange('rspeed', 0, -1)).to eq [
20
+ '{"file":"1_spec.rb","time":1.0}',
21
+ '{"file":"2_spec.rb","time":2.0}',
22
+ '{"file":"3_spec.rb","time":3.0}',
23
+ ]
15
24
  end
16
25
  end
@@ -2,13 +2,13 @@
2
2
 
3
3
  require 'support/env_mock'
4
4
 
5
- RSpec.describe RSpeed::Variable, '.tmp' do
6
- it { expect(described_class.tmp).to eq('rspeed_tmp') }
5
+ RSpec.describe RSpeed::Variable, '.profile' do
6
+ it { expect(described_class.profile).to eq('rspeed_profile_1') }
7
7
 
8
8
  context 'when env name is given' do
9
9
  it 'includes the name' do
10
10
  EnvMock.mock(rspeed_name: 'name') do
11
- expect(described_class.tmp).to eq('rspeed_tmp_name')
11
+ expect(described_class.profile).to eq('rspeed_profile_name_1')
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe RSpeed::Variable, 'PROFILE_PATTERN' do
4
+ it { expect(described_class::PROFILE_PATTERN).to eq('rspeed_profile_*') }
5
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def delete_file(file_path = 'rspeed.csv')
3
+ def delete_file(file_path)
4
4
  File.delete(file_path) if File.exist?(file_path)
5
5
  end
6
6
 
7
- def truncate_file(file_path = 'rspeed.csv')
8
- File.open(file_path, 'w') { |file| file.truncate(0) }
7
+ def truncate_profiles
8
+ RSpeed::Redis.destroy(RSpeed::Variable::PROFILE_PATTERN)
9
9
  end
10
10
 
11
- def populate_csv_file
11
+ def populate_profiles
12
12
  data = [
13
- '2.0,./spec/2_0_spec.rb',
14
- '1.5,./spec/1_5_spec.rb',
15
- '1.1,./spec/1_1_spec.rb',
16
- '0.7,./spec/0_7_spec.rb',
17
- '0.4,./spec/0_4_spec.rb',
18
- '0.3,./spec/0_3_spec.rb',
19
- '0.2,./spec/0_2_spec.rb',
20
- ].join("\n")
13
+ { file: './spec/2_0_spec.rb', time: 2.0 }.to_json,
14
+ { file: './spec/1_5_spec.rb', time: 1.5 }.to_json,
15
+ { file: './spec/1_1_spec.rb', time: 1.1 }.to_json,
16
+ { file: './spec/0_7_spec.rb', time: 0.7 }.to_json,
17
+ { file: './spec/0_4_spec.rb', time: 0.4 }.to_json,
18
+ { file: './spec/0_3_spec.rb', time: 0.3 }.to_json,
19
+ { file: './spec/0_2_spec.rb', time: 0.2 }.to_json,
20
+ ]
21
21
 
22
- File.open('rspeed.csv', 'a') { |file| file.write(data) }
22
+ RSpeed::Splitter.new.append(items: data, key: RSpeed::Variable.profile)
23
23
  end
24
24
 
25
25
  def redis_object
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -187,7 +187,6 @@ files:
187
187
  - spec/models/rspeed/env/port_spec.rb
188
188
  - spec/models/rspeed/env/result_key_spec.rb
189
189
  - spec/models/rspeed/env/rspeed_spec.rb
190
- - spec/models/rspeed/env/tmp_spec.rb
191
190
  - spec/models/rspeed/observer/after_spec.rb
192
191
  - spec/models/rspeed/observer/after_suite_spec.rb
193
192
  - spec/models/rspeed/observer/before_spec.rb
@@ -213,13 +212,13 @@ files:
213
212
  - spec/models/rspeed/splitter/rename_spec.rb
214
213
  - spec/models/rspeed/splitter/split_spec.rb
215
214
  - spec/models/rspeed/variable/append_name_spec.rb
216
- - spec/models/rspeed/variable/csv_spec.rb
217
215
  - spec/models/rspeed/variable/default_partner_spec.rb
218
216
  - spec/models/rspeed/variable/key_spec.rb
219
217
  - spec/models/rspeed/variable/pipe_name_spec.rb
218
+ - spec/models/rspeed/variable/pipe_profile_spec.rb
220
219
  - spec/models/rspeed/variable/pipes_pattern_spec.rb
220
+ - spec/models/rspeed/variable/profile_pattern_spec.rb
221
221
  - spec/models/rspeed/variable/result_spec.rb
222
- - spec/models/rspeed/variable/tmp_spec.rb
223
222
  - spec/spec_helper.rb
224
223
  - spec/support/common.rb
225
224
  - spec/support/coverage.rb
@@ -251,13 +250,13 @@ summary: Split and speed up your RSpec tests.
251
250
  test_files:
252
251
  - spec/spec_helper.rb
253
252
  - spec/models/rspeed/variable/pipes_pattern_spec.rb
254
- - spec/models/rspeed/variable/tmp_spec.rb
253
+ - spec/models/rspeed/variable/pipe_profile_spec.rb
255
254
  - spec/models/rspeed/variable/default_partner_spec.rb
256
- - spec/models/rspeed/variable/csv_spec.rb
257
255
  - spec/models/rspeed/variable/append_name_spec.rb
258
256
  - spec/models/rspeed/variable/result_spec.rb
259
257
  - spec/models/rspeed/variable/key_spec.rb
260
258
  - spec/models/rspeed/variable/pipe_name_spec.rb
259
+ - spec/models/rspeed/variable/profile_pattern_spec.rb
261
260
  - spec/models/rspeed/redis/destroy_spec.rb
262
261
  - spec/models/rspeed/redis/get_spec.rb
263
262
  - spec/models/rspeed/redis/clean_spec.rb
@@ -284,7 +283,6 @@ test_files:
284
283
  - spec/models/rspeed/observer/after_spec.rb
285
284
  - spec/models/rspeed/env/pipe_spec.rb
286
285
  - spec/models/rspeed/env/rspeed_spec.rb
287
- - spec/models/rspeed/env/tmp_spec.rb
288
286
  - spec/models/rspeed/env/port_spec.rb
289
287
  - spec/models/rspeed/env/name_spec.rb
290
288
  - spec/models/rspeed/env/host_spec.rb
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'support/env_mock'
4
-
5
- RSpec.describe RSpeed::Env, '.tmp_key' do
6
- context 'when key is not setted on env' do
7
- it 'returns default value' do
8
- expect(described_class.tmp_key).to eq 'rspeed_tmp'
9
- end
10
- end
11
-
12
- context 'when key is setted on env' do
13
- it 'returns env value' do
14
- EnvMock.mock(respeed_tmp_key: 'result_customer') do
15
- expect(described_class.tmp_key).to eq 'result_customer'
16
- end
17
- end
18
- end
19
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RSpeed::Variable, 'CSV' do
4
- it { expect(described_class::CSV).to eq('rspeed.csv') }
5
- end