Created
August 19, 2008 13:29
-
-
Save foca/6177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe FooController do | |
stub_record_and_collection_urls! | |
describe "GET /foos" do | |
# ... | |
end | |
# ... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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