Skip to content

Instantly share code, notes, and snippets.

@tario
Created December 28, 2011 16:55
Show Gist options
  • Save tario/1528666 to your computer and use it in GitHub Desktop.
Save tario/1528666 to your computer and use it in GitHub Desktop.
picomock
class TestClass
def foo(x)
@instance_var + $global.to_i
print self.method_name, "\n"
x**2
end
end
suite( 1 => 1, 2 => 4, 3 => 9, 4 => 16 ).test(
mock(:@instance_var => 800, :$global => "999", :method_name => lambda{"xxxx"}) {
TestClass.new
}.method(:foo)
)
suite( 1 => 1, 2 => 4, 3 => 9, 4 => 16 ).test(
TestClass.new.
mock(:@instance_var => 800, :$global => "999", :method_name => lambda{"xxxx"}).
method(:foo)
)
suite( 1 => 1, 2 => 4, 3 => 9, 4 => 16 ).test(
TestClass.new.
mock(:@instance_var => 800, :$global => mock(:to_i => 999), :method_name => "xxxx").
method(:foo)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment