Skip to content

Instantly share code, notes, and snippets.

@ChuckJHardy
Created August 22, 2016 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChuckJHardy/ea62ef16df72901aa65230b06cdfd9f6 to your computer and use it in GitHub Desktop.
Save ChuckJHardy/ea62ef16df72901aa65230b06cdfd9f6 to your computer and use it in GitHub Desktop.
Command Spec
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