Sha256: 019fa60173dc6b665353660ffaeadfd7186bf34abcfb5465c1c88cb644eac632

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 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)
          @controller = controller
          filters_key?
        end

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

        def negative_failure_message
          "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

28 entries across 20 versions & 4 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.4.2/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.9.1.beta.3 vendor/bundle/gems/shoulda-matchers-1.4.2/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
devise_sociable-0.1.0 vendor/bundle/gems/shoulda-matchers-1.4.2/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.9.1.beta vendor/bundle/gems/shoulda-matchers-1.4.2/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.9.0 vendor/bundle/gems/shoulda-matchers-1.4.2/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.4.2 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.3.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.2.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.3.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.3.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.4.1 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.4.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.8.1 vendor/bundle/gems/shoulda-matchers-1.3.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.2.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.3.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb