rspec/rspec-rails — Issue #477: RSpec not working with defaults in route
Author: tenpaiyomi
Created: 2012-01-03 07:44:27+00:00
State: open

I've attempted this with 2 test scenarios. A code snipped is as followed:

require 'spec_helper'

module Facts
describe CoreController do
context 'without passing parameters' do
subject do
get 'request_fact'
response.body
end
end

it 'should return an error stating parameters must be passed' do
should == {:s => 1, :e => "Parameters must be passed."}.to_json
end
end

My route looks like this:

get "/read" => "core#request_fact", :defaults => {:type => 0}

In that form, when I run the test, I get an ActionController::RoutingError (No route matches {:controller=>"facts/core", :action=>"request_fact"}). If I remove the defaults portion, the spec works fine. Am I missing something in this? In both cases, the raked route matches the route which it's saying it cannot find.