Geoffrey Roguelon
2014-Mar-31 07:57 UTC
Rails Engine ActionController::UrlGenerationError on functional tests
Hi,
I'm looking for a way to solve an error I get each times I run my
functional tests. I have a Rails Engine gem (isolated), I have a JSON
action with a route declared. But each times I use the method get in a test
I get an ActionController::UrlGenerationError exception.
Here an example of code with the problem:
# config/routes.rbMyEngine::Engine.routes.draw do
resources :cats, only: [:show], format: 'json'end
# test/dummy/config/routes.rbRails.application.routes.draw do
mount MyEngine::Engine => '/my_engine'end
# app/controllers/my_engine/cats_controller.rbmodule MyEngine
class CatsController < ApplicationController
def show
render json: { hello: 'world' }
end
endend
# test/controllers/my_engine/cats_controller_test.rbmodule MyEngine
class CatsControllerTest < ActionController::TestCase
test 'should get success' do
get :show, id: 42
assert_response :success
end
endend
Here is an example of test return:
1) Error:
MyEngine:: CatsControllerTest#test_should_get_success:
ActionController::UrlGenerationError: No route matches
{:action=>"show", :controller=>"my_engine/cats",
:id=>"42"}
Anyone have an idea to solve this problem?
Thanks.
-----
Geoffrey Roguelon
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/06e665fd-7a76-4d98-9d91-171e4dc6bf6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seemingly Similar Threads
- Rails 3.1 Engines: Full vs. Mountable
- rails 3 engine under dynamic scope
- (Beginner) ActionController::UrlGenerationError - No route matches
- Why does 'extend ActiveSupport::Concern' cause `undefined method 'recycle!'`?
- Engines Generator & Howto Extract an Engine
