c42/rspec-http — Issue #3: Matchers not available in request specs
Author: claco
Created: 2012-02-03 16:57:23+00:00
State: open

Everything works great when you are doing controller specs:

describe MyController do
if "#index" do
get :index
response.should be_ok
end
end

Matchers are not loaded when performing request specs:

describe "/my" do
it "index" do
get "/my/index"
response.should be_ok
end
end

The former returns an ActionController::TestResponse. The latter returns ActionDispatch::TestResponse.

No amount of futzing with Rspec.config seems to load the matchers the way I'd expect. Not sure how they get matchers into ActionController::TestResponse?

config.include RSpec::Rails::ResponseCodeMatchers, :type => :requests
config.include RSpec::Rails::ResponseCodeMatchers, :type => :requests

This appears to work. ActionDispatch::TestResponse.send(:include, RSpec::Rails::ResponseCodeMatchers)

At the very least, maybe mention in the docs that these matchers are for controller specs and not for request specs.