jonleighton / focused_controller

MIT License
467 stars 27 forks source link

RSpec and included member routes in a resource #23

Closed ccocchi closed 12 years ago

ccocchi commented 12 years ago

Given the following routes

focused_controller_routes do
 resources :posts do
  get :something, on: :member
 end
end

and the following functionnal test

require 'spec_helper'
require 'focused_controller/rspec_functional_helper'

describe PostsController do
  include FocusedController::RSpecFunctionalHelper

  describe PostsController::Something do
    it "should not raise an error" do
      get
    end
  end
end

I got the this error

 1) PostsController PostsController::Something should not raise an error
     Failure/Error: get
     ActionController::RoutingError:
       No route matches {:controller=>"posts_controller/something", :action=>"call"}

This action works perfectly when accessed via a browser and routes seem to be correctly defined when running rake routes

ccocchi commented 12 years ago

It seems also to be the same problem with routes inside a scope such as

scope 'foos' do
 get '/bar' => 'foos#bar'
end

Trying to test FoosController::Bar will raise the same RoutingError

ccocchi commented 12 years ago

It is better to supply an id to a member route... :s