Rspec-rails: undefined method `controller' for RSpec::ExampleGroups::PaymentIQPaymentIQController:Class

Created on 24 May 2014  ·  5Comments  ·  Source: rspec/rspec-rails

Hi again,

First of all many thanks for the RC1 release. Look forward to upgrade all my projects to use it.

I run in to the error message in the title any time I try to do something fancy in a controller spec.

controller do
    before_filter :ensure_player_exists
    before_filter :ensure_session_exists, only: [:create]

    def index
      render :text => 'index called'
    end

    def create
      render :text => 'create called'
    end
  end

Not sure why this broke between beta2 and rc1. Any suggestions? I don't see the controller { } macro being deprecated anywhere.

Most helpful comment

Aha so I figured it out, RSpec stopped working for sub folders. If I have a spec like /spec/controllers/v1/receipts_controller_spec it isn't picked up as a controller spec anymore. If I add :type => :controller it works.

Is that how it should be?

All 5 comments

Probably your using inferred controller specs and missed the deprecation, tag your spec with type: :controller or enable inferred specs.

Aha so I figured it out, RSpec stopped working for sub folders. If I have a spec like /spec/controllers/v1/receipts_controller_spec it isn't picked up as a controller spec anymore. If I add :type => :controller it works.

Is that how it should be?

Yep.

You can enable the deprecated behaviour with RSpec.configuration.infer_spec_type_from_file_location!

Awesome thanks @JonRowe

Was this page helpful?
0 / 5 - 0 ratings