Sha256: 6bfc6a24d569a4d11f0fc010b4332be516e28dad757b2e95858713a46fb1ae61

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

Contents

module Shoulda # :nodoc:
  module Matchers
    module ActionController # :nodoc:
      # Ensures that filter_parameter_logging is set for the specified key.
      #
      # Example:
      #
      #   it { should filter_param(:password) }
      def filter_param(key)
        FilterParamMatcher.new(key)
      end

      class FilterParamMatcher # :nodoc:
        def initialize(key)
          @key = key.to_s
        end

        def matches?(controller)
          filters_key?
        end

        def failure_message_for_should
          "Expected #{@key} to be filtered; filtered keys: #{filtered_keys.join(', ')}"
        end

        def failure_message_for_should_not
          "Did not expect #{@key} to be filtered"
        end

        def description
          "filter #{@key}"
        end

        private

        def filters_key?
          filtered_keys.include?(@key)
        end

        def filtered_keys
          Rails.application.config.filter_parameters.map(&:to_s)
        end
      end
    end
  end
end

Version data entries

17 entries across 16 versions & 2 rubygems

Version Path
shoulda-matchers-2.4.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-2.4.0.rc1 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-2.3.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-1.0.0 vendor/bundle/gems/shoulda-matchers-2.2.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-2.2.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-2.1.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-2.1.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-1.0.0.beta2 vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-2.0.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.6 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.5 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.4 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.2 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.1 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.5.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb