RSpec raising routing errors where Rails doesn't?

Hopefully someone here can help me figure out why the ERB:

<% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html => {:class
=> ‘fund’, :multipart => true}) do |f| %>

raises an error in my specs:

No route matches {:action=>“index”}

but works fine in my app and generates the following, desired HTML:

.

Many thanks in advance.

RSL

On Tue, Aug 19, 2008 at 5:17 PM, RSL ___ [email protected] wrote:

.

If you’re using edge rails, there was a recent change that broke rspec:

http://rspec.lighthouseapp.com/projects/5645/tickets/497

I haven’t had time to address this, nor will I for at least several
days. I will have time to merge in a patch, however, if anybody else
has the time to fix the problem.

Cheers,
David

Thanks, David but unfortunately for me this is happening on 2.0.2 Rails,
with rspec/rspec-rails, from about a month and a half ago. Must be
something else. Here’s hoping someone else has run across this. :confused:

Please post the code example.

I gave up on solving this. Very very strange that it even occurs.
Stranger still that I circumvented the problem by writing a view helper
to construct the url like this:

def private_fund_form_url(fund)
if fund.new_record?
funds_url(:host => PRIVATE_HOST)
else
fund_url(fund, :host => PRIVATE_HOST)
end
end

[which is what the form_for should have been doing internally anyhow]
and specing it in isolation. It passes in the helper specs so I just
stub out the helper call in the view specs and all is well. Thanks again
for your help, David.

RSL

David C. wrote:

Please post the code example.

I have reduced the failing Rspec code to this:

require File.dirname(FILE) + ‘/…/…/spec_helper’

describe “funds/_form.fbml.erb” do
before(:each) do
@current_user = stub_model(User)
@fund = stub_model(Fund, :supporters => [@current_user])
assigns[:fund] = @fund
template.stub!(:current_user).and_return(@current_user)
end

it “should just render the template” do
render “funds/_form.fbml.erb”
end
end

which errors with:

ActionView::TemplateError in ‘funds/_form.fbml.erb should just render
the template’
No route matches {:action=>“index”}
On line #6 of funds/_form.fbml.erb

3:   <p>You can still change your email address and payment details 

at any time. Payment details are verified against fraud on the day of
payout to your good cause.


4:
5:
6: <% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html =>
{:class => ‘fund’, :multipart => true}) do |f| %>
7: <%= error_messages_for :fund %>
8:


9: Name for your fund:

/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1408:in 

generate' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:124:inrewrite_path’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:103:in
rewrite_url' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:81:inrewrite’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:616:in
url_for' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:71:insend’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:71:in
url_for' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:395:inhtml_options_for_form’
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/object/misc.rb:28:in
returning' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:393:inhtml_options_for_form’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:38:in
form_tag' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_helper.rb:185:inform_for’
app/views/funds/_form.fbml.erb:6:in
_run_erb_47app47views47funds47_form46fbml46erb' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:insend’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in
compile_and_render_template' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:inrender_template’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in
render_file' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:inrender_for_file’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:861:in
render_with_no_layout' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:270:inrender_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in
render' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in
render' vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb:130:insend’
vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb:130:in
render' spec/views/funds/_form.fbml.erb_spec.rb:13 vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:ininstance_eval’
vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in
eval_block' vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:inexecute’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in
timeout' vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:inexecute’
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in
execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:ineach’
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in
execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:inrun’
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in
run' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:ineach’
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in
run' vendor/plugins/rspec/lib/spec/runner/options.rb:106:inrun_examples’
vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run’
script/spec:4

Hope that helps and thanks for your assistance.

RSL

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs