aboutsummaryrefslogtreecommitdiffstats
path: root/spec/board_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2015-04-14 17:27:31 -0400
committerTeddy Wing2015-04-14 17:27:31 -0400
commiteba2547a194b801596b43f6ba37b7d1b867a321d (patch)
treee0a845af0cac64fa3e17752cf14a5cbeb988825e /spec/board_spec.rb
parent1863abc09ec0af8a0026d4c170bfd50b11032b76 (diff)
downloadtic-tac-toe-eba2547a194b801596b43f6ba37b7d1b867a321d.tar.bz2
Board: Method to unintelligently convert string coordinates to array
Take string coordinates in the form ":integer:,:integer:" and convert them to [integer, integer]. We'll be using these converted coordinate values to place a piece on the board.
Diffstat (limited to 'spec/board_spec.rb')
-rw-r--r--spec/board_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/board_spec.rb b/spec/board_spec.rb
index 86b4276..8d2b8da 100644
--- a/spec/board_spec.rb
+++ b/spec/board_spec.rb
@@ -22,4 +22,17 @@ EOF
]
end
end
+
+ describe '#transform_coordinates' do
+ it 'converts string coordinates to an array' do
+ @board.transform_coordinates('0,4').must_equal [0, 4]
+ end
+
+ it "returns nil if coordinates don't match the format" do
+ @board.transform_coordinates('4').must_be_nil
+ @board.transform_coordinates('4 2').must_be_nil
+ @board.transform_coordinates('booyakacha').must_be_nil
+ @board.transform_coordinates('booya,kacha').must_be_nil
+ end
+ end
end