Environment: Rails 3.2.12, rspec 2.12
I'm trying to bootstrap an app with a very simple routing test. The test is failing, and I can't see what could be wrong.
Here's the test that fails:
# spec/routing/meow_route_spec.rb
require 'spec_helper'
describe "meow routes" do
it "routes post /meows to meows#create" do
expect(:post => "/meows").to route_to(
:controller => "meows",
:action => "create",
)
end
end
And my route:
# config/routes.rb
Meowserver::Application.routes.draw do
resources :meows
end
rake routes
tells me:
polk:meowserver dpassage$ rake routes
meows GET /meows(.:format) meows#index
POST /meows(.:format) meows#create
new_meow GET /meows/new(.:format) meows#new
edit_meow GET /meows/:id/edit(.:format) meows#edit
meow GET /meows/:id(.:format) meows#show
PUT /meows/:id(.:format) meows#update
DELETE /meows/:id(.:format) meows#destroy
But when I run rspec, I get this error:
1) meow routes routes post /meows to meows#create
Failure/Error: expect(:post => "/meows").to route_to(
No route matches "/meows"
# ./spec/routing/meow_route_spec.rb:4:in `block (2 levels) in <top (required)>'
What on earth is going on here? Those are really the only files of consequence in my app so far - not even any controllers or models, just trying to build it from the outside in.
Well, it turns out that adding in the controller resolves the issue. I added this:
# app/controllers/meows_controller.rb
class MeowsController < ApplicationController
end
...and now the test passes. Very frustrating error message!