Sha256: a7a5ff5d64ffa6c6d3494080afc4e0980e4085ef1c3d6131dc4d61fea0a3a33f

Contents?: true

Size: 1.18 KB

Versions: 53

Compression:

Stored size: 1.18 KB

Contents

module Shoulda # :nodoc:
  module ActionController # :nodoc:
    module Matchers

      # 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_params? && filters_key?
        end

        def failure_message
          "Expected #{@key} to be filtered"
        end

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

        def description
          "filter #{@key}"
        end

        private

        def filters_params?
          @controller.respond_to?(:filter_parameters)
        end

        def filters_key?
          filtered_value == '[FILTERED]'
        end

        def filtered_value
          filtered = @controller.send(:filter_parameters,
                                      @key.to_s => @key.to_s)
          filtered[@key.to_s]
        end

      end

    end
  end
end

Version data entries

53 entries across 53 versions & 15 rubygems

Version Path
Flamefork-shoulda-2.10.1 lib/shoulda/action_controller/matchers/filter_param_matcher.rb
Flamefork-shoulda-2.10.2 lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.0 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.1 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.10 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.11 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.12 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.13 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.14 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.15 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.16 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.17 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.2 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.3 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.4 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.5 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.6 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.7 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
auser-poolparty-1.3.8 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb
fairchild-poolparty-1.3.17 vendor/gems/shoulda/lib/shoulda/action_controller/matchers/filter_param_matcher.rb