Skip to content

Conversation

alindeman
Copy link
Contributor

I have a Rails Engine with routes defined in my app.
After upgrade all routing tests fail with No route matches...

I was trying to debug the MyEngine::Engine.routes.router and here's the diff
On latest rspec-rails @ast is always nil.

@@ -1,13 +1,14 @@
 pry(#<RSpec::Core::ExampleGroup::Nested_14::Nested_1>)> @routes.router
-=> #<Journey::Router:0xa1eb388
+=> #<Journey::Router:0xa4e6150
  @options=
   {:parameters_key=>"action_dispatch.request.path_parameters",
    :request_class=>ActionDispatch::Request},
  @params_key="action_dispatch.request.path_parameters",
  @request_class=ActionDispatch::Request,
  @routes=
-  #<Journey::Routes:0xa1eb3ec
-   @ast=nil,
+  #<Journey::Routes:0xa4e61b4
+   @ast=
+    /signup(.:format)|/login(.:format)|/logout(.:format)|/signup(.:format)|/login(.:format)|/start(.:format)|/start(.:format)|/sessions(.:format)|/sessions/new(.:format)|/sessions/:id(.:format)|/passwords(.:form
    @named_routes=
     {"signup"=>
-      #<Journey::Route:0xc685004
\ No newline at end of file
+      #<Journey::Route:0xa6d40c0
\ No newline at end of file

@alindeman
Copy link
Contributor

Thanks for the report! Could you create a small Rails app that demonstrates the problem and push it up to GitHub? I'm not able to figure out what's going on with just the details so far.

@stas
Copy link
Author

stas commented Jan 13, 2013

Here's an example application:
https://github.com/stas/rspec-rails-668

master should be green, rspec_rails_2.12.1 fails for me. The only diff is the rspec-rails gem version.

Thank you for taking a look.

@alindeman
Copy link
Contributor

The repo is incredibly helpful, thank you. I'm digging into the issue now.

@alindeman
Copy link
Contributor

I'm working on this, but it's unlikely to continue working by setting @routes. I hope to have a good solution for this by the next release.

@alindeman
Copy link
Contributor

A workaround for now is:

before do
  assertion_instance.instance_variable_set(:@routes, @routes)
end

I know this sucks, but we're in a hard spot trying to support this alongside Rails 4. I'm working on it soon :)

@stas
Copy link
Author

stas commented Feb 23, 2013

Thanks,
looking forward for the fix.

@gemyago
Copy link

gemyago commented Feb 24, 2013

+1

* For example, when testing Rails engines

[Closes #668]
@alindeman
Copy link
Contributor

@stas, @evgeny-myasishchev: would you look at my proposed solution, try it out, and give feedback? The branch name is routing_specs_can_set_routes and the docs are here: https://github.com/rspec/rspec-rails/pull/668/files#L0L-1

@gemyago
Copy link

gemyago commented Feb 24, 2013

Just tried, works great!

@stas
Copy link
Author

stas commented Feb 25, 2013

:shipit:

alindeman added a commit that referenced this pull request Mar 1, 2013
Allow routing specs to access engine routes
@alindeman alindeman merged commit 2087db0 into master Mar 1, 2013
@alindeman
Copy link
Contributor

Merged. It will appear in rspec-rails 2.14. You can pin to a git revision in the time being, but hopefully it won't be terribly long before another release :)

@alindeman alindeman deleted the routing_specs_can_set_routes branch March 1, 2013 01:17
@stas
Copy link
Author

stas commented Mar 1, 2013

Thank you.

@gemyago
Copy link

gemyago commented Mar 1, 2013

Great, thanks a lot! :)

@tvdeyen
Copy link

tvdeyen commented Mar 21, 2013

Thank you so much for fixing this. ❤️ ❤️
It works like charm.

Thanks 👏

alindeman added a commit that referenced this pull request Apr 6, 2013
* For example, when testing Rails engines

[Closes #668]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants