Created
February 3, 2009 11:09
-
-
Save anonymous/57476 to your computer and use it in GitHub Desktop.
Dirty spec for a Rails helper using #url_for
This file contains 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 ApplicationHelper | |
def self_url(options = Hash.new) | |
url_for(request.path_parameters.merge(options)) | |
end | |
end | |
describe ApplicationHelper do | |
describe '#self_url' do | |
def do_it(options = Hash.new) | |
helper.self_url(options) | |
end | |
it "returns the url for the current request's path parameters" do | |
@params = Hash.new | |
@args = { :alpha => :beta } | |
@request = mock(Object, :path_parameters => @params) | |
@params.should_receive(:merge).with(@args).and_return(@params) | |
helper.should_receive(:request).and_return(@request) | |
helper.should_receive(:url_for).with(@params).and_return("URL") | |
do_it(@args).should == "URL" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment