Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.include usage in following manner: config.include "ModuleName", type: "Multiple tags here" #1349

Closed
jiggneshhgohel opened this issue Apr 8, 2015 · 4 comments

Comments

@jiggneshhgohel
Copy link

Environment

Rails 4.2.0
ruby-2.2.1 [ x86_64 ]
rspec-core  3.2.2
rspec-rails   3.2.1

In my /spec/rails_helper.rb I have included Devise helpers for spec files tagged with type: :controller

RSpec.configure do |config|
   ...
   ....
   config.include Devise::TestHelpers, type: :controller
end

Now I need these helpers for spec files tagged with type: :request. Is there a provision to specify multiple values to :type option? For e.g.

config.include Devise::TestHelpers, type: :controller, :request, or

config.include Devise::TestHelpers, types: [:controller, :request]

Thanks,
Jiggneshh

@cupakromer
Copy link
Member

You will need to write the include again:

config.include Devise::TestHelpers, type: :request

The metadata matches are exact. So type: [:controller, :request] would expect a spec that has the type specified as an array.

@yagudaev
Copy link

I agree with @jiggneshhgohel seeing the following code my instinct that it was similar to rails and I could change it to types and it would all work. I do understand what you are talking about @cupakromer but it is a technical reason. The design of the interface should accommodate what the user would expect to be able to do.

At the very least, we should give a warning "Unsupported filter option types" if possible.

@Jack-Barry
Copy link

Jack-Barry commented Jan 30, 2018

I just use a loop to save some keystrokes. (That way I can also include the ControllerMacros module without having to get WET.)

for type in [:controller, :request] do
  config.include Devise::Test::ControllerHelpers, type: type
  config.extend ControllerMacros, type: type
end

@aldrienht
Copy link

My aim is to have type for :controller & :model
the above suggestion does not worked in my end.
I tried to remove the type argument, and it works for both :controller & :model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants