diff --git a/lor b/lor new file mode 100644 index 0000000..4155581 --- /dev/null +++ b/lor @@ -0,0 +1,24 @@ +.FF + +Failures: + + 1) MessageBoard should receive slow down from conductor + Failure/Error: conductor.see_danger_coming! + NameError: + undefined local variable or method `conductor' for # + # ./train_spec.rb:22:in `block (2 levels) in ' + + 2) MessageBoard should receive a slow down confirmation from the engineer + Failure/Error: message_board.should_receive(:confirm_slow_down!) + (#).confirm_slow_down!(any args) + expected: 1 time with any arguments + received: 0 times with any arguments + # ./train_spec.rb:26:in `block (2 levels) in ' + +Finished in 0.01176 seconds +3 examples, 2 failures + +Failed examples: + +rspec ./train_spec.rb:20 # MessageBoard should receive slow down from conductor +rspec ./train_spec.rb:25 # MessageBoard should receive a slow down confirmation from the engineer diff --git a/train.rb b/train.rb index bc6dbcb..e2bf9f5 100644 --- a/train.rb +++ b/train.rb @@ -12,4 +12,22 @@ def see_danger_coming! end class Engineer + + def slow_down! + end +end + +class MessageBoard + + attr_reader :message_board + + def initialize(message_board) + @message_board = message_board + end + + def confirm + @message_board.slow_down! + end + + end \ No newline at end of file diff --git a/train_spec.rb b/train_spec.rb index de4cff5..fe13fe1 100644 --- a/train_spec.rb +++ b/train_spec.rb @@ -1,5 +1,6 @@ require 'rspec' require './train' + describe Conductor do let(:engineer) { Engineer.new } @@ -10,4 +11,34 @@ conductor.see_danger_coming! end -end \ No newline at end of file +end + +describe MessageBoard do + + let(:message_board) { MessageBoard.new(engineer) } + let(:conductor) { Conductor.new(engineer)} + let(:engineer) { Engineer.new } + + it "should receive slow down from conductor" do + message_board.should_receive(:slow_down!) + conductor.see_danger_coming! + end + + it "should receive a slow down confirmation from the engineer" do + message_board.confirm.should_receive(:slow_down!) + engineer.should_receive(: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. \ No newline at end of file