Skip to content

Instantly share code, notes, and snippets.

@jtrupiano
Created May 17, 2009 19:00
Show Gist options
  • Save jtrupiano/113104 to your computer and use it in GitHub Desktop.
Save jtrupiano/113104 to your computer and use it in GitHub Desktop.
require 'mocha'
# Used such that the named_scope chain will return a count of 0 to allow us to test "empty" messages in views
def mock_empty_named_scope(model, named_scope)
# For any instance of model, stub the named_scope and have it return an object that responds to :count with a value of 0
model.any_instance.stubs(named_scope).returns(mock(:count => 0))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment