Skip to content

Instantly share code, notes, and snippets.

Created February 3, 2009 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/57476 to your computer and use it in GitHub Desktop.
Save anonymous/57476 to your computer and use it in GitHub Desktop.
Dirty spec for a Rails helper using #url_for
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