Permalink
Browse files

Merge branch 'fix_tests_for_2.1'

  • Loading branch information...
2 parents 671fe2d + bed85e0 commit 04b610bf6093271e16b3199f53e9836fee6dd803 @threedaymonk committed Feb 9, 2014
Showing with 13 additions and 6 deletions.
  1. +2 −0 Gemfile
  2. +7 −3 Gemfile.lock
  3. +3 −2 lib/battleship/board.rb
  4. +1 −1 test/console_renderer_test.rb
View
@@ -2,3 +2,5 @@ source "https://rubygems.org"
gem "colored"
gem "mocha"
gem "parallel"
+gem "minitest"
+gem "rake"
View
@@ -2,15 +2,19 @@ GEM
remote: https://rubygems.org/
specs:
colored (1.2)
- metaclass (0.0.1)
- mocha (0.10.0)
+ metaclass (0.0.2)
+ minitest (5.2.2)
+ mocha (1.0.0)
metaclass (~> 0.0.1)
- parallel (0.5.9)
+ parallel (0.9.2)
+ rake (10.1.1)
PLATFORMS
ruby
DEPENDENCIES
colored
+ minitest
mocha
parallel
+ rake
View
@@ -1,6 +1,6 @@
module Battleship
class Board
-
+
def initialize(size, expected_fleet, positions)
@size = size
@expected_fleet = expected_fleet
@@ -72,11 +72,12 @@ def valid_fleet?(fleet)
def expand_positions(positions)
return [] unless positions.is_a?(Enumerable)
positions.map{ |p| expand_position(*p) }
- rescue ArgumentError
+ rescue ArgumentError, NoMethodError
[]
end
def expand_position(x, y, length, direction)
+ raise ArgumentError unless [:across, :down].include?(direction)
dx, dy = direction == :across ? [1, 0] : [0, 1]
(0 ... length).map{ |i| [x + i * dx, y + i * dy] }
end
@@ -1,7 +1,7 @@
require "minitest/autorun"
require "battleship/console_renderer"
require "stringio"
-require "mocha"
+require "mocha/mini_test"
class ConsoleRendererTest < MiniTest::Unit::TestCase
include Battleship

0 comments on commit 04b610b

Please sign in to comment.