2013-08-04 21:06:56 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SnapshotCreator do
|
|
|
|
|
|
|
|
let(:snapshot_creator) { SnapshotCreator.new }
|
|
|
|
|
|
|
|
describe '#create' do
|
2013-08-13 17:33:38 +00:00
|
|
|
let(:stdout) { double('stdout', :each_until => nil) }
|
|
|
|
let(:terminal) { double('terminal', :feed => nil, :snapshot => snapshot,
|
|
|
|
:release => nil) }
|
2013-08-04 21:06:56 +00:00
|
|
|
let(:snapshot) { double('snapshot') }
|
|
|
|
|
|
|
|
subject { snapshot_creator.create(80, 24, stdout, 31.4) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Terminal).to receive(:new).with(80, 24) { terminal }
|
2013-08-13 17:33:38 +00:00
|
|
|
allow(stdout).to receive(:each_until).and_yield(1.2, "\xBCółć")
|
2013-08-04 21:06:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses Terminal to generate a snapshot' do
|
|
|
|
subject
|
|
|
|
|
2013-08-13 17:33:38 +00:00
|
|
|
expect(terminal).to have_received(:feed).with("\xBCółć")
|
2013-08-04 21:06:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'gets the bytes from stdout for half duration (whole seconds)' do
|
|
|
|
subject
|
|
|
|
|
2013-08-13 17:33:38 +00:00
|
|
|
expect(stdout).to have_received(:each_until).with(15)
|
2013-08-04 21:06:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the snapshot from the Terminal' do
|
|
|
|
expect(subject).to be(snapshot)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|