Skip to content

Instantly share code, notes, and snippets.

@foca
Created August 19, 2008 13:29
Show Gist options
  • Save foca/6177 to your computer and use it in GitHub Desktop.
Save foca/6177 to your computer and use it in GitHub Desktop.
describe FooController do
stub_record_and_collection_urls!
describe "GET /foos" do
# ...
end
# ...
end
module CollectionAndRecordPathSpecHelpers
%w(collection_path collection_url record_path record_url).each do |method|
define_method method {|*args| controller.send(method, *args) }
end
def self.included(base)
def base.stub_record_and_collection_urls!
before do
controller.stub!(:collection_path).and_return("/collection/path")
controller.stub!(:collection_url).and_return("http://test.host/collection/path")
controller.stub!(:record_path).and_return("/record/path")
controller.stub!(:record_url).and_return("http://test.host/collection/path")
end
end
end
end
Spec::Runner.configure do |config|
config.include CollectionAndRecordPathSpecHelpers, :type => :controller
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment