Created
August 22, 2016 11:35
-
-
Save ChuckJHardy/ea62ef16df72901aa65230b06cdfd9f6 to your computer and use it in GitHub Desktop.
Command Spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'command' | |
describe Command do | |
let(:instance) { described_class.new(input, robotic_rover) } | |
let(:robotic_rover) do | |
instance_double( | |
"RoboticRover", | |
position: '0 0 N', | |
move: '0 1 N', | |
right_turn: '0 0 E', | |
left_turn: '0 0 W' | |
) | |
end | |
describe '#position_change' do | |
subject(:position_change) { instance.position_change } | |
context 'when advance command' do | |
let(:input) { 'M' } | |
it 'alters a rovers position' do | |
expect(position_change).to eq robotic_rover.move | |
end | |
end | |
context 'when right command' do | |
let(:input) { 'R' } | |
it 'alters a rovers direction' do | |
expect(position_change).to eq robotic_rover.right_turn | |
end | |
end | |
context 'when left command' do | |
let(:input) { 'L' } | |
it 'alters the rovers direction' do | |
expect(position_change).to eq robotic_rover.left_turn | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment