explicit-parameters
explicit-parameters copied to clipboard
`parameters[action_name]` not available while running the specs
Not sure where the issue is coming from (maybe rspec-rails) but this line https://github.com/byroot/explicit-parameters/blob/master/lib/explicit_parameters/controller.rb#L31 is causing issues when running rspec on a Rails app.
This was my fix: https://github.com/jeromegn/explicit-parameters/blob/master/lib/explicit_parameters/controller.rb#L31
However, I'm pretty sure there's a better way to do it.
I failed to reproduce the issue from a new app. Could you give me more informations please?
- Rails version
- rspec-rails version
- rspec version
- the order of those gems and explicit parameters in your gemfile.
Thanks!
Sure,
rails 4.2.0 rspec-rails 3.2.1 (rspec-core 3.2.0)
Order:
- rails
- explicit-parameters
- rspec-rails
I'm also using a small spec helper to apply default params to all my requests, that could be at fault...
require 'active_support/concern'
require 'active_support/core_ext/module/aliasing'
module DefaultParams
extend ActiveSupport::Concern
def process_with_default_params(action, method, parameters={}, session={}, flash=nil)
process_without_default_params(action, method, default_params.merge(parameters || {}), session, flash)
end
included do
let(:default_params) { {} }
alias_method_chain :process, :default_params
end
end
RSpec.configure do |config|
config.include(DefaultParams, :type => :controller)
end