Created
November 12, 2013 11:25
-
-
Save sgerrand/7429380 to your computer and use it in GitHub Desktop.
An example using Minitest::Mock, using the version (4.7) available in the Ruby standard library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Roro | |
def initialize(host, speakers = []) | |
@host = host | |
@speakers = speakers | |
end | |
def start | |
@host.speak | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
require_relative 'roro' | |
class TestRoro < MiniTest::Unit::TestCase | |
def setup | |
@mock = MiniTest::Mock.new | |
@mock.expect :speak, 'Welcome to roro!' | |
end | |
def test_start_returns_welcome_message | |
@roro = Roro.new(@mock) | |
assert_equal 'Welcome to roro!', @roro.start | |
@mock.verify | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment