Replace env.output interface with an IO like object

This commit is contained in:
Thibault Jouan
2013-12-23 00:50:25 +00:00
parent e8b0900721
commit d670d5dbdd
6 changed files with 23 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ require 'spec_helper'
module Producer::Core
describe Env do
let(:output) { double 'output' }
subject(:env) { Env.new }
describe '#initialize' do
@@ -12,15 +13,21 @@ module Producer::Core
it 'assigns no default target' do
expect(env.target).not_to be
end
context 'when output is given as argument' do
subject(:env) { Env.new(output: output) }
it 'assigns the given output' do
expect(env.instance_eval { @output }).to eq output
end
end
end
describe '#output' do
let(:stdout) { StringIO.new }
subject(:env) { Env.new(output: output) }
it 'writes the given string to the assigned IO with a record separator' do
env.output = stdout
env.output 'some content'
expect(stdout.string).to eq "some content\n"
it 'returns the assigned output' do
expect(env.output).to eq output
end
end