Skip to content

Instantly share code, notes, and snippets.

@jdunphy
Created June 15, 2009 22:12
Show Gist options
  • Save jdunphy/130383 to your computer and use it in GitHub Desktop.
Save jdunphy/130383 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'test/unit'
require 'mocha'
class Foo
def self.foo(a_param)
a_param.upcase
end
end
class FooTest < Test::Unit::TestCase
def test_foo_should_get_a_thing
Foo.expects(:foo).with("a string").returns("A STRING")
Foo.foo("a string")
end
def test_foo_works_with_partial_matches
Foo.expects(:foo).with { |value| value =~ /ring/ }.returns("SOMETHING")
Foo.foo(%22a string")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment