spec/models/rspeed/splitter/append_spec.rb in rspeed-0.5.1 vs spec/models/rspeed/splitter/append_spec.rb in rspeed-0.5.2
- old
+ new
@@ -1,35 +1,19 @@
# frozen_string_literal: true
RSpec.describe RSpeed::Splitter, '#append' do
subject(:splitter) { described_class.new }
+ let!(:redis) { redis_object }
+
it 'appends file and time on rspeed key' do
- splitter.append [[1, '1_spec.rb'], [2, '2_spec.rb']]
+ splitter.append(
+ items: [{ file: '1_spec.rb', time: 1 }.to_json, { file: '2_spec.rb', time: 2 }.to_json],
+ key: 'rspeed'
+ )
- expect(splitter.get('rspeed_tmp')).to eq [
- '{"file":"2_spec.rb","time":2.0}',
- '{"file":"1_spec.rb","time":1.0}',
+ expect(redis.lrange('rspeed', 0, -1)).to eq [
+ '{"file":"1_spec.rb","time":1}',
+ '{"file":"2_spec.rb","time":2}',
]
- end
-
- context 'when files is not given' do
- before do
- truncate_file
- populate_csv_file
- end
-
- it 'read csv and append file and time on rspeed key' do
- splitter.append
-
- expect(splitter.get('rspeed_tmp')).to eq [
- '{"file":"./spec/0_2_spec.rb","time":0.2}',
- '{"file":"./spec/0_3_spec.rb","time":0.3}',
- '{"file":"./spec/0_4_spec.rb","time":0.4}',
- '{"file":"./spec/0_7_spec.rb","time":0.7}',
- '{"file":"./spec/1_1_spec.rb","time":1.1}',
- '{"file":"./spec/1_5_spec.rb","time":1.5}',
- '{"file":"./spec/2_0_spec.rb","time":2.0}',
- ]
- end
end
end