Created
August 22, 2016 11:35
Command Spec
This file contains 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