-
-
Save blowmage/98ab11f9171761612fd6 to your computer and use it in GitHub Desktop.
Test with a mock and a stub
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" | |
class RestClient | |
def self.get action | |
end | |
end | |
class MyClass | |
def do_it! | |
RestClient.get :index | |
end | |
end | |
class TestMyClass < Minitest::Test | |
def test_mock_and_stub | |
mock = Minitest::Mock.new | |
mock.expect :does_something, "return value" | |
RestClient.stub :get, :index do | |
mock.does_something | |
end | |
MyClass.new.do_it! | |
mock.verify | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment