Created
November 14, 2010 04:04
-
-
Save matschaffer/675895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❷ > ruby quicktest.rb | |
Loaded suite quicktest | |
Started | |
. | |
Finished in 0.001060 seconds. | |
1 tests, 3 assertions, 0 failures, 0 errors, 0 skips | |
Test run options: --seed 33394 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'test/unit' | |
require 'mocha' | |
class GiftIdea | |
def self.safely | |
end | |
end | |
class QuickTest < Test::Unit::TestCase | |
def test_chaining_mocks | |
@generated_gift = "a gift!" | |
mock_gift = mock('safely_save_gift') | |
mock_gift.expects(:create).with(:desc => "SF4").returns(@generated_gift) | |
GiftIdea.expects(:safely).returns(mock_gift).once | |
assert_equal "a gift!", GiftIdea.safely.create(:desc => "SF4") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment