Skip to content

Instantly share code, notes, and snippets.

@khebbie
Created March 28, 2010 17:00
Show Gist options
  • Save khebbie/346872 to your computer and use it in GitHub Desktop.
Save khebbie/346872 to your computer and use it in GitHub Desktop.
My first stab at flexmock
require 'rubygems'
require 'flexmock/test_unit'
class Dog
def initialize(tail)
@tail = tail
end
def IsHappy?
if(@tail.wag)
true
else
false
end
end
end
class TestDog < Test::Unit::TestCase
def test_dog_wags
tail_mock = flexmock(:wag => true)
dog = Dog.new(tail_mock)
assert_equal true, dog.IsHappy?
end
def test_dog_walks_nicely
jump_mock = flexmock(:jump => false)
assert_equal false, jump_mock.jump
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment