Sha256: 2f2cd60cf5f594cbcb1ae730800e0d0b91814f87217f77d3522a6a1fe8f08a0a

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 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 { |filter| filter.to_s }
        end
      end

    end
  end
end

Version data entries

16 entries across 13 versions & 4 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.6.2 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.6.1 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.6.0 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.5.4 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.5.3 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.5.2 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
challah-0.5.1 vendor/bundle/gems/shoulda-matchers-1.0.0/lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.0.0 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.0.0.beta3 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
yetanothernguyen-shoulda-matchers-1.0.0.beta3 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.0.0.beta2 lib/shoulda/matchers/action_controller/filter_param_matcher.rb
shoulda-matchers-1.0.0.beta1 lib/shoulda/matchers/action_controller/filter_param_matcher.rb