From 5e214b74ddd1293dd4b7db6cea855b59d8b64366 Mon Sep 17 00:00:00 2001 From: Mike Adeleke Date: Wed, 11 Dec 2013 16:37:01 -0600 Subject: [PATCH] Great improvement. couple of questions --- minitest/navy.rb | 38 ++++++++++++++++++++++++++++++++++++-- minitest/navy_test.rb | 30 ++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/minitest/navy.rb b/minitest/navy.rb index c672e0a..51c1485 100644 --- a/minitest/navy.rb +++ b/minitest/navy.rb @@ -7,15 +7,49 @@ def fire_upon_target @battleship.fire! end + def has_battleship + battleship = Battleship.new + end end class Battleship - attr_reader :ammunition + attr_reader :ammunition, :request def initialize - @ammunition = 100 + @ammunition = 10 + @request = request end def fire! @ammunition = @ammunition - 1 end + + def request + true + end + + def more_ammunition + true + end + + def verify + if "hit" + "hit" + else + "miss" + end + end end + +class Fate + attr_reader :ammunition + + def initalize + @hit = hit + @miss = miss + end + + def outcome + [:hit, :miss].sample + end +end + diff --git a/minitest/navy_test.rb b/minitest/navy_test.rb index de35ec0..a946fc1 100644 --- a/minitest/navy_test.rb +++ b/minitest/navy_test.rb @@ -12,17 +12,43 @@ def setup def test_can_tell_the_battleship_to_fire @battleship.expect :fire!, nil @admiral.fire_upon_target - @battleship.verify + @battleship.verify.must_equal (true) + end + + def test_has_battleship + battleship = Battleship.new end end -class TestBattleship< MiniTest::Unit::TestCase +class TestBattleship < MiniTest::Unit::TestCase def test_will_decrease_ammunition_when_firing battleship = Battleship.new starting_ammunition = battleship.ammunition battleship.fire! assert_equal (starting_ammunition - 1), battleship.ammunition end + + def test_ammunition + battleship = Battleship.new + starting_ammunition = battleship.ammunition + end + + def test_request_more_ammunition + battleship = Battleship.new + battleship.request.must_equal (true) + end + + def test_battleship_can_receive_more_ammunition + battleship = Battleship.new + starting_ammunition = battleship.ammunition + battleship.more_ammunition.must_equal (true) + end +end + +class TestFate < MiniTest::Unit::TestCase + def test_outcome + #Not sure here + end end describe Battleship do