Skip to content

Instantly share code, notes, and snippets.

@jkburges
Last active January 6, 2016 10:53
Show Gist options
  • Save jkburges/965b0c584f93887411b5 to your computer and use it in GitHub Desktop.
Save jkburges/965b0c584f93887411b5 to your computer and use it in GitHub Desktop.
require 'minitest'
require 'minitest/mock'
class Test
def initialize
@vals = [1, 2, 3, 4, 5]
end
def a
b
end
def b
@vals.shift
end
end
mock = MiniTest::Mock.new
mock.expect(:call, 'a')
mock.expect(:call, 'b')
test = Test.new
test.stub(:b, mock) do
puts test.a
puts test.a
end
mock.verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment