Reputation: 3435
I have this spec:
specify { expect(:post => admin_featured_path()).to route_to(:controller => 'admin/featured', :action => 'create')}
I cant' make it pass however it seems logical that the post to the route should be routed to the create action...
This is my route file:
namespace :admin do
resources :featured, only: [:index, :update, :destroy, :create]
end
This is the failure message:
1) Featured routes
Failure/Error: specify { expect(:post => admin_featured_path()).to route_to(:controller => 'admin/featured', :action => 'create')}
ActionController::UrlGenerationError:
No route matches {:action=>"update", :controller=>"admin/featured"} missing required keys: [:id]
# ./spec/routing/featured_spec.rb:7:in `block (2 levels) in <top (required)>'
Upvotes: 1
Views: 85
Reputation: 29349
{:post => admin_featured_path}.should route_to(:controller => 'admin/featured', :action => 'create')
or
{:post => "admin/featured"}.should route_to(:controller => "admin/featured", :action => 'create')
Upvotes: 0
Reputation: 10754
This should work (untested):
page = post admin_featured_path
expect(page).to route_to(:controller => 'admin/featured', :action => 'create')
Upvotes: 1