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

Messageboard added #7

Open
wants to merge 1 commit 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
5 changes: 5 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions .idea/train-message_expectations.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions train.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
class Conductor

attr_reader :engineer
attr_reader :engineer, :messageboard

def initialize(engineer)
def initialize(engineer, messageboard)
@engineer = engineer
@messageboard = messageboard
end

def see_danger_coming!
engineer.slow_down!
messageboard.slow_down!
end
end

class Engineer

attr_reader :messageboard

def initialize(messageboard)
@messageboard = messageboard
end

def confirm_slow_down
messageboard.confirm_slow_down
end

end

class MessageBoard
Copy link
Member

Choose a reason for hiding this comment

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

The MessageBoard class is empty. Won't it blow up if you call .confirm_slow_down on it?


end
16 changes: 11 additions & 5 deletions train_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
require './train'
describe Conductor do

let(:engineer) { Engineer.new }
let(:conductor) { Conductor.new(engineer)}
let(:engineer) { Engineer.new(messageboard) }
let(:conductor) { Conductor.new(engineer, messageboard)}
let(:messageboard) {double}

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

it "should confirm slow down to messageboard" do
messageboard.should_receive(:confirm_slow_down)
engineer.confirm_slow_down
end

end