Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created November 14, 2010 04:04
Show Gist options
  • Save matschaffer/675895 to your computer and use it in GitHub Desktop.
Save matschaffer/675895 to your computer and use it in GitHub Desktop.
❷ > 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
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