Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created MessageBoard class and tests #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions train.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
class Conductor

attr_reader :engineer
attr_reader :message_board

def initialize(engineer)
@engineer = engineer
def initialize(message_board)
@message_board = message_board
end

def see_danger_coming!
engineer.slow_down!
message_board.slow_down!
end
end

class Engineer
attr_reader :message_board

def initialize(message_board)
@message_board = message_board
end

def slow_down
message_board.confirm_slow_down
end
end

class MessageBoard
end
18 changes: 14 additions & 4 deletions train_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
require './train'
describe Conductor do

let(:engineer) { Engineer.new }
let(:conductor) { Conductor.new(engineer)}
let(:conductor) { Conductor.new(message_board) }
let(:message_board) { mock }

it "should tell the engineer to slow down" do
engineer.should_receive(:slow_down!)
it "should tell the message board to slow down" do
message_board.should_receive(:slow_down!)
conductor.see_danger_coming!
end

end

describe Engineer do
let(:engineer) { Engineer.new(message_board) }
let(:message_board) { mock }

it "should send message board a slow down confirmation" do
message_board.should_receive(:confirm_slow_down)
engineer.slow_down
end
end