Implement input handling in Env
This commit is contained in:
parent
d347b8d6f5
commit
a871bb4009
@ -1,10 +1,11 @@
|
|||||||
module Producer
|
module Producer
|
||||||
module Core
|
module Core
|
||||||
class Env
|
class Env
|
||||||
attr_reader :output
|
attr_reader :input, :output
|
||||||
attr_accessor :target
|
attr_accessor :target
|
||||||
|
|
||||||
def initialize(output: $stdout)
|
def initialize(input: $stdin, output: $stdout)
|
||||||
|
@input = input
|
||||||
@output = output
|
@output = output
|
||||||
@target = nil
|
@target = nil
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,10 @@ module Producer::Core
|
|||||||
subject(:env) { Env.new }
|
subject(:env) { Env.new }
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
|
it 'assigns $stdin as the default output' do
|
||||||
|
expect(env.input).to be $stdin
|
||||||
|
end
|
||||||
|
|
||||||
it 'assigns $stdout as the default output' do
|
it 'assigns $stdout as the default output' do
|
||||||
expect(env.output).to be $stdout
|
expect(env.output).to be $stdout
|
||||||
end
|
end
|
||||||
@ -13,6 +17,15 @@ module Producer::Core
|
|||||||
expect(env.target).not_to be
|
expect(env.target).not_to be
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when input is given as argument' do
|
||||||
|
let(:input) { double 'input' }
|
||||||
|
subject(:env) { described_class.new(input: input) }
|
||||||
|
|
||||||
|
it 'assigns the given input' do
|
||||||
|
expect(env.input).to eq input
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when output is given as argument' do
|
context 'when output is given as argument' do
|
||||||
let(:output) { double 'output' }
|
let(:output) { double 'output' }
|
||||||
subject(:env) { described_class.new(output: output) }
|
subject(:env) { described_class.new(output: output) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user