I'm looking for some help outputting the activity messages into the command line window. I know this may seem backwards but this is the task I've been given. I've already written tests so that they all pass but I need to convert the below activity into the command line window. It's just a game that resembles the Impossible Machine game.
Firstly I need to create a process which starts the Impossible Machine, then simulate each of the activities being initiated in succession before finishing.
Of what I understand, all the messages displayed should be sent to the STDOUT channel. These are some of the tests that have been written:
module ImpossibleMachine
# Input and output constants processed by subprocesses
DOWN_ARROW = 1
UP_ARROW = 2
RIGHT_ARROW = 3
REPEAT_ARROW = 4
END_PROCESS = 5
START_CURRENT = 6
# RSpec Tests
describe Game do
describe "#start The impossible machine game" do
before(:each) do
@process = []
@output = double('output').as_null_object
@game = Game.new(@output)
end
it "sends a welcome message" do
@output.should_receive(:puts).with('Welcome to the Impossible Machine!')
@game.start
end
it "should contain a method created_by which returns the students name" do
myname = @game.created_by
myname.should == "My Name"
end
it "should perform lifts_lever_turns_wheel activity which returns REPEAT_ARROW" do
@output.should_receive(:puts).with("Input: #{UP_ARROW}, Activity: Heave_ho_squeek_squeek")
@process[1] = @game.lifts_lever_turns_wheel(UP_ARROW)
@process[1].should == REPEAT_ARROW
end
it "sends a finishing message" do
@output.should_receive(:puts).with('...Game finished.')
@game.finish
end
end
end
My only knowledge is that I need to start the module like this and then proceed to add code below it so that it outputs the activity messages to the command line:
module ImpossibleMachine
@process = []
g = Game.new(STDOUT)
Hope that makes sense.