Skip to content

Instantly share code, notes, and snippets.

@leosoto
Created September 5, 2010 21:51
Show Gist options
  • Save leosoto/566357 to your computer and use it in GitHub Desktop.
Save leosoto/566357 to your computer and use it in GitHub Desktop.
describe Something do
context "when it is too old" do
# Two options here:
# (a) make it too old by changing the internal state
# Pros: Simple
# Cons: If you change the definition of what is "too old" you have to change many tests
before { subject.updated_at = 2.years.ago }
# (b) stub the too_old? method
# Pros: Resistant to changes of what "too old" exactly means
# Cons: Forces the implementation to use a specific method.
before { subject.stubs(:too_old?).returns(true) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment