Skip to content
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
11 changes: 10 additions & 1 deletion train.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
class Conductor

attr_reader :engineer
attr_reader :engineer, :message_board

def initialize(engineer)
@engineer = engineer
end

def initialize(message_board)
@message_board = message_board
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you left the existing def initialize(engineer)

The class works, but only because Ruby is a "last method defined wins" --- you should remove the older initiation and engineer.slow_down!

end

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

class Engineer
end

class MessageBoard
end
10 changes: 10 additions & 0 deletions train_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,15 @@
engineer.should_receive(:slow_down!)
conductor.see_danger_coming!
end

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

it "should tell confirm the slow down when engineer slows down" do
engineer.should_receive(:slow_down!)
message_board.should_receive(:confirm_slow_down!)
end

end