Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion minitest/navy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Admiral
attr_reader :battleship
def initialize(battleship)
@battleship = battleship
end
Expand All @@ -12,7 +13,7 @@ def fire_upon_target
class Battleship
attr_reader :ammunition
def initialize
@ammunition = 100
@ammunition = 10
end

def fire!
Expand Down
19 changes: 17 additions & 2 deletions minitest/navy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "minitest/autorun"
require "minitest/mock"

class TestAdmiral < MiniTest::Unit::TestCase
class TestAdmiral < MiniTest::Test

def setup
@battleship = MiniTest::Mock.new
Expand All @@ -16,7 +16,7 @@ def test_can_tell_the_battleship_to_fire
end
end

class TestBattleship< MiniTest::Unit::TestCase
class TestBattleship< MiniTest::Test
def test_will_decrease_ammunition_when_firing
battleship = Battleship.new
starting_ammunition = battleship.ammunition
Expand All @@ -32,4 +32,19 @@ def test_will_decrease_ammunition_when_firing
battleship.fire!
battleship.ammunition.must_equal (starting_ammunition -1)
end

it "should verify that starting_ammunition equals 10" do
battleship = Battleship.new
battleship.ammunition.must_equal (10)
end
end

describe Admiral do
it "should verify that Admiral has a battleship" do
battleship = Battleship.new
admiral = Admiral.new(battleship)
admiral.battleship.must_equal (battleship)
end
end