I've tried to use the recommended way (from the Rails Guides) to test routes generated in plugins, but the test keeps failing.
What's odd is that if I reload the routes AFTER creating the route (or so I think), the test fails, but if I let the test go through once (e.g. using autotest), then the route gets recognized on subsequent attempts.
Here's the code:
describe "named route report_with_last_name_smith_path" do
before :all do
Reports::Application.routes.draw do
match "/report_some_report_for_us" => "report#report_some_report_for_us",
:as => :report_some_report_for_us
end
Rails.application.reload_routes! # If I leave this out, then the test
# passes the second time that autotest/autospec
# go through.
end
it "route for every record" do
{:get => '/report_some_report_for_us'}.should route_to(:controller => 'report', :action => 'report_some_report_for_us')
end
end
Any idea how to make it pass all the time?
Hmm. The README for rspec-rails-2 for rails-3 at http://github.com/rspec/rspec-rails has a "Routing specs" section. There's no need for the before :all
with the latest RSpec, perhaps?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With