Sha256: 9e9871482ce0dc0e85029dd147bcda2d9c0dd5ca6f9353542c6e9ce23c96e42c

Contents?: true

Size: 710 Bytes

Versions: 12

Compression:

Stored size: 710 Bytes

Contents

require 'unit_spec_helper'

describe Shoulda::Matchers::ActionController::FilterParamMatcher, type: :controller do
  it 'accepts filtering a filtered parameter' do
    filter(:secret)

    expect(nil).to filter_param(:secret)
  end

  it 'accepts filtering a parameter matching a filtered regex' do
    filter(/(?!tip)pin(?!g)/)

    expect(nil).to filter_param(:pin)
  end

  it 'rejects filtering an unfiltered parameter' do
    filter(:secret)
    matcher = filter_param(:other)

    expect(matcher.matches?(nil)).to eq false

    expect(matcher.failure_message).to match(/Expected other to be filtered.*secret/)
  end

  def filter(param)
    Rails.application.config.filter_parameters = [param]
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
shoulda-matchers-3.1.3 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-4.0.0.rc1 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.1.2 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.1.1 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.1.0 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.0.1 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.0.0 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-3.0.0.rc1 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb