neilmarion
neilmarion

Reputation: 2382

@controller instance variable in Rspec

Just curious. How is the @controller instance variable inside the controller specs being instantiated? And where?

Upvotes: 2

Views: 234

Answers (1)

Paul Nicholson
Paul Nicholson

Reputation: 557

I believe this is actually being done by ActionController::TestCase::Behavior#setup_controller_request_and_response, which is wired up by RSpec::Rails::SetupAndTeardownAdapter#setup, which is included by RSpec::Rails::RailsExampleGroup and used by RSpec::Rails::ControllerExampleGroup. :)

bundle open rspec-rails is an easy way to start looking at how this stuff works.

HTH!

Upvotes: 3

Related Questions