2014-08-30 17:38:47 +00:00
|
|
|
require 'rails_helper'
|
2013-09-10 19:29:17 +00:00
|
|
|
|
|
|
|
describe AsciicastFramesFileUpdater do
|
|
|
|
|
|
|
|
let(:updater) { described_class.new(file_writer) }
|
|
|
|
let(:file_writer) { double('file_writer') }
|
|
|
|
|
2014-09-23 19:29:19 +00:00
|
|
|
describe '#update', needs_terminal_bin: true do
|
2013-09-10 19:29:17 +00:00
|
|
|
let(:asciicast) { create(:asciicast) }
|
|
|
|
let(:film) { double('film', :frames => frames) }
|
|
|
|
let(:frames) { [1, 2] }
|
|
|
|
|
|
|
|
subject { updater.update(asciicast) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Film).to receive(:new).with(asciicast.stdout, kind_of(Terminal)) {
|
|
|
|
film
|
|
|
|
}
|
|
|
|
allow(file_writer).to receive(:write_enumerable) do |file, frames|
|
|
|
|
file << frames.to_json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates stdout_frames file on asciicast' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(asciicast.stdout_frames.read).to eq('[1,2]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|