require './lib/toy_robot_simulator/robot.rb'
require './tests/test_reporter_interface'
require 'minitest/autorun'

class RobotTest < MiniTest::Unit::TestCase
  include ReporterInterfaceTest

  def setup
    @placement = MiniTest::Mock.new
    @robot = @object = Robot.new(placement: @placement)
    @_ = Object.new
  end

  def test_that_it_delegates_placing
    @placement.expect(:update!, nil, [@_])
    @robot.place(@_)
    @placement.verify
  end

  def test_that_it_moves
    adjacent_placement = Object.new
    @placement.expect(:adjacent, adjacent_placement)

    @robot.move
    assert_equal adjacent_placement, @robot.send('placement')
  end

  def test_that_it_turns_right
    new_placement = Object.new
    @placement.expect(:rotate!, new_placement, [90])

    @robot.right
    assert_equal new_placement, @robot.send('placement')
  end

  def test_that_it_turns_left
    new_placement = Object.new
    @placement.expect(:rotate!, new_placement, [-90])

    @robot.left
    assert_equal new_placement, @robot.send('placement')
  end

  def test_that_it_delegates_reporting
    @placement.expect(:report, nil)
    @robot.report
    @placement.verify
  end
end

require './lib/toy_robot_simulator/robot.rb'
require './tests/test_reporter_interface'
require 'minitest/autorun'

class RobotTest < MiniTest::Unit::TestCase
  include ReporterInterfaceTest

  def setup
    @observer = MiniTest::Mock.new
    @robot = @object = Robot.new(placement: @observer)
  end

  def teardown
    @observer = nil
    @robot = nil
  end

  def test_that_it_places
    @observer.expect(:update, nil, [nil])
    @robot.place(nil)
    @observer.verify
  end

  def test_that_it_moves
    @observer.expect(:advance, nil)
    @robot.move
    @observer.verify
  end

  def test_that_it_turns_right
    @observer.expect(:rotate, nil, [90])
    @robot.right
    @observer.verify
  end

  def test_that_it_turns_left
    @observer.expect(:rotate, nil, [-90])
    @robot.left
    @observer.verify
  end

  def test_that_it_reports
    @observer.expect(:report, nil)
    @robot.report
    @observer.verify
  end
end

Rewrite RobotTest to verify delegation
Rewrite RobotTest to verify delegation

This commit focuses on verifying that command messages are being
sent. It renames public interface methods for the placement object.
It removes the ! from rotate!() and update!(). It does
this to target a more consisten interface.
