[rspec-users] RSpec raising routing errors where Rails doesn't?

RSL ___ lists at ruby-forum.com
Wed Aug 20 09:35:00 EDT 2008


David Chelimsky 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.</p>
    4: </div>
    5:
    6: <% form_for(@fund, :url => {:host => PRIVATE_HOST}, :html => 
{:class => 'fund', :multipart => true}) do |f| %>
    7:   <%= error_messages_for :fund %>
    8:   <p>
    9:     <label for="fund_name">Name for your fund:</label>

    /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:in 
`rewrite_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:in 
`rewrite'
    /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:in 
`send'
    /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:in 
`html_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:in 
`html_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:in 
`form_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:in 
`send'
    /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:in 
`render_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:in 
`render_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:in 
`render_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:in 
`measure'
    /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:in 
`send'
    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:in 
`instance_eval'
    vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in 
`eval_block'
    vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in 
`execute'
    /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:in 
`execute'
    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:in 
`each'
    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:in 
`run'
    vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in 
`run'
    vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in 
`each'
    vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in 
`run'
    vendor/plugins/rspec/lib/spec/runner/options.rb:106:in 
`run_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
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list