how to test with and without strong_parameters?

Recently integrated a patch for strong_parameters into a fork of active_admin and wanted to add tests for it, but I’m not sure what the best way of adding tests is for something that can optionally support strong_parameters.

For those that are trying to write tests that support controller functionality with and without strong_parameters in their gem, how do you do that? (I guess this question will apply to those wanting to support both rails 3 and 4 in a gem and be able to test controller additions without having to have a separate fork for rails 4).

Is there a switch for enabling and disabling strong_parameters such that it could be disabled and then just enable it for a single test?

Just wanted to follow-up on this thread, even though it was answered in another.

A feature addition to disable SP, somewhat similar to how whitelisting was enabled/disabled in Rails 3 was turned down (who knows- maybe that will be reconsidered at some point, but dhh said no). But for SP, in your tests that use Rails 3.2, you may just be able to have models that and some that don’t include ActiveModel::ForbiddenAttributesProtection:
include ::ActiveModel::ForbiddenAttributesProtection

or something that was suggested was to use the appraisal gem:

And some projects like ActiveAdmin also have their own method to test with different gemsets by including logic in the Gemfile, e.g. in v0.5.0’s Gemfile (in

ACTIVE_ADMIN_PATH = File.dirname(__FILE__) unless defined?(ACTIVE_ADMIN_PATH)

require File.expand_path('spec/support/detect_rails_version', ACTIVE_ADMIN_PATH)

rails_version = detect_rails_version

gem 'rails',          rails_version


case rails_version

when /^3\.0/

# Do nothing, bundler should figure it out

when /^3\.(1|2)/

# These are the gems you have to have for Rails 3.1 to be happy

gem 'sass-rails'

gem 'uglifier'


raise "Rails #{rails_version} is not supported yet"