Skip to content

Commit

Permalink
Merge branch 'fix_tests_for_2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
threedaymonk committed Feb 9, 2014
2 parents 671fe2d + bed85e0 commit 04b610b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source "https://rubygems.org"
gem "colored"
gem "mocha"
gem "parallel"
gem "minitest"
gem "rake"
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions lib/battleship/board.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Battleship
class Board

def initialize(size, expected_fleet, positions)
@size = size
@expected_fleet = expected_fleet
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/console_renderer_test.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 04b610b

Please sign in to comment.