You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/spec/services/json_file_writer_spec.rb

29 lines
597 B
Ruby

require 'rails_helper'
describe JsonFileWriter do
let(:writer) { described_class.new }
describe '#write_enumerable' do
let(:file) { StringIO.new }
let(:enumerable) { [item_1, item_2] }
let(:item_1) { double('item_1', :to_json => 'a') }
let(:item_2) { double('item_2', :to_json => 'b') }
subject { writer.write_enumerable(file, enumerable) }
before do
subject
end
it 'writes the enumerable to the file in json format' do
expect(file.string).to eq('[a,b]')
end
it 'closes the file' do
expect(file).to be_closed
end
end
end