Skip to content

Instantly share code, notes, and snippets.

@bhenderson
Forked from phiggins/minimock_example.rb
Created May 21, 2011 05:18
Show Gist options
  • Save bhenderson/984275 to your computer and use it in GitHub Desktop.
Save bhenderson/984275 to your computer and use it in GitHub Desktop.
Minimock Example
require 'minitest/mock'
require 'net/http'
m = MiniTest::Mock.new.expect(:foo, true, [Net::HTTP::Post.new("/")])
p m.foo(1)
begin
m.verify
rescue Exception => e
puts "expected to raise"
p [:exception, e.class, :message, e.message]
end
m = MiniTest::Mock.new.expect(:bar, true, [Net::HTTP::Post])
p m.bar(Net::HTTP::Post.new("/"))
p m.verify
puts "not expected to raise"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment