Implement Action#output (delegates to env.output)
This commit is contained in:
parent
103b9d1230
commit
e567c61e4e
@ -1,6 +1,11 @@
|
|||||||
module Producer
|
module Producer
|
||||||
module Core
|
module Core
|
||||||
class Action
|
class Action
|
||||||
|
require 'forwardable'
|
||||||
|
|
||||||
|
extend Forwardable
|
||||||
|
def_delegator :@env, :output
|
||||||
|
|
||||||
attr_accessor :env, :arguments
|
attr_accessor :env, :arguments
|
||||||
|
|
||||||
def initialize(env, *args)
|
def initialize(env, *args)
|
||||||
|
@ -3,7 +3,7 @@ module Producer
|
|||||||
module Actions
|
module Actions
|
||||||
class Echo < Action
|
class Echo < Action
|
||||||
def apply
|
def apply
|
||||||
env.output.puts arguments.first
|
output.puts arguments.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ module Producer
|
|||||||
module Actions
|
module Actions
|
||||||
class ShellCommand < Action
|
class ShellCommand < Action
|
||||||
def apply
|
def apply
|
||||||
env.output.puts env.remote.execute(arguments.first)
|
output.puts env.remote.execute(arguments.first)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,5 +17,12 @@ module Producer::Core
|
|||||||
expect(action.arguments).to eq arguments
|
expect(action.arguments).to eq arguments
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#output' do
|
||||||
|
it 'delegates to env output' do
|
||||||
|
expect(action.env).to receive(:output).with(:content)
|
||||||
|
action.output :content
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ module Producer::Core
|
|||||||
subject(:echo) { Actions::Echo.new(env, text) }
|
subject(:echo) { Actions::Echo.new(env, text) }
|
||||||
|
|
||||||
describe '#apply' do
|
describe '#apply' do
|
||||||
it 'writes the given string to env.output with a record separator' do
|
it 'writes the given string to env output with a record separator' do
|
||||||
echo.apply
|
echo.apply
|
||||||
expect(env.output.string).to eq "hello\n"
|
expect(env.output.string).to eq "hello\n"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user