Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ def see_danger_coming!
end

class Engineer
end

class MessageBoard

def slow_down!(engineer)
end

def confirm_slow_down!(conductor)
end

end
29 changes: 28 additions & 1 deletion train_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rspec'
require './train'

describe Conductor do

let(:engineer) { Engineer.new }
Expand All @@ -10,4 +11,30 @@
conductor.see_danger_coming!
end

end
end

describe MessageBoard do

let(:message_board) { MessageBoard.new }

it "should receive slow down from conductor" do
message_board.should_receive(:slow_down!)
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 are not performing any actions or calling any methods.

All you are doing with this message expectation is saying that for this test to pass, the message_board should receive a call of slow_down!

The normal flow here would be to then execute some code to see if it happened.

it "should receive slow down from conductor" do
  message_board.should_receive(:slow_down!)
  conductor.see_danger_coming!
end

end

it "should receive a slow down confirmation from the engineer" do
message_board.should_receive(:confirm_slow_down!)
end
end

# Your Assignment
# ---------------

# In most circumstances like this, there's a sort of MessageBoard. Let's create
# the idea of a MessageBoard class that both the engineer and the conductor know
# about.

# 1. When the conductor sees trouble, the conductor tells the `message_board` to slow down
# 2. When the engineer slows down, the engineer tells the `message_board` `confirm_slow_down`

# Use whichever mocking tool you liked the best or are interested in. If you
# don't know what to choose, go with RSpec.