thoughtbot/shoulda-matchers — pull request #150 by tom-kuca (2012-09-09 20:27:15+00:00)
Title: response is undefined when using respond_with and subject

I have tried rails with rspec and shoulda, but I run into following issue:

The example in controller spec:

```ruby
describe '#index' do
subject { get :index }
it { should respond_with(:success) }
end
```

fails with:

```
Failure/Error: it { should respond_with(:forbidden) }
NoMethodError:
undefined method `response' for #
```

If I substitute the line
```ruby
it { should respond_with(:success) }
```
with some rspec matcher, i.e.
```ruby
it { should redirect_to(login_path) }
```
it works. I looked up to the difference between rspec matchers and shoulda matchers and realized that rspec matchers pass the controller object to the matcher at constructor, like here: https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/matchers/redirect_to.rb. I modified ```respond_with``` matcher in a similar way and it fixes my issue and doesn't break any other spec or feature.

Versions:

* rails (3.2.8)
* rspec (2.11.0)
* shoulda-matchers (1.0.0)