Skip to content

Instantly share code, notes, and snippets.

@gabrieljoelc
Created May 8, 2014 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrieljoelc/09587467e26ee6b6ece3 to your computer and use it in GitHub Desktop.
Save gabrieljoelc/09587467e26ee6b6ece3 to your computer and use it in GitHub Desktop.
From http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9: "Partial stubbing is when you want use a “real object” in your tests but want to stub some of the methods of that object, for example to avoid hitting the network or to freeze the time. These kinds of stubs are easily added in ruby thanks to it's dynamic workings. Le…
describe Book do
it "glorifies published at" do
book = Book.new
def book.published_at
Time.new(2012, 1, 2)
end
book.glorified_published_at.must_equal "The most awesome and first Monday of the glorious year of 2012"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment