aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--board.rb4
-rw-r--r--spec/board_spec.rb25
2 files changed, 22 insertions, 7 deletions
diff --git a/board.rb b/board.rb
index fe81bba..5db93fd 100644
--- a/board.rb
+++ b/board.rb
@@ -8,7 +8,9 @@ class Board
end
def render
- "...\n" * 3
+ output = ''
+ @board.each {|row| output << row.join + "\n" }
+ output
end
# Raises an ArgumentError if integer conversion fails
diff --git a/spec/board_spec.rb b/spec/board_spec.rb
index a5c45ef..ae1bdd0 100644
--- a/spec/board_spec.rb
+++ b/spec/board_spec.rb
@@ -6,8 +6,16 @@ describe Board do
@board = Board.new
end
+ it 'starts with a grid of dots' do
+ @board.instance_variable_get('@board').must_equal [
+ ['.', '.', '.'],
+ ['.', '.', '.'],
+ ['.', '.', '.']
+ ]
+ end
+
describe '#render' do
- it 'prints a grid' do
+ it 'must be a grid' do
@board.render.must_equal <<EOF
...
...
@@ -15,12 +23,17 @@ describe Board do
EOF
end
- it 'starts with a grid of dots' do
- @board.instance_variable_get('@board').must_equal [
- ['.', '.', '.'],
+ it 'must be the correct board' do
+ @board.instance_variable_set(:@board, [
+ ['.', 'X', 'O'],
+ ['X', '.', '.'],
['.', '.', '.'],
- ['.', '.', '.']
- ]
+ ])
+ @board.render.must_equal <<EOF
+.XO
+X..
+...
+EOF
end
end