Sha256: 8a486f0c46f4ea427c10b5287672bfa281e5a38b59d5770873fa5d2e939f5866

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

module Remarkable
  module ActionController
    module Matchers
      # Do not inherit from ActionController::Base since it don't need all macro stubs behavior.
      class FilterParamsMatcher < Remarkable::Base #:nodoc:
        arguments :collection => :params, :as => :param

        assertions :respond_to_filter_params?
        collection_assertions :is_filtered?

        protected

          def respond_to_filter_params?
            @subject.respond_to?(:filter_parameters)
          end

          def is_filtered?
            filtered = @subject.send(:filter_parameters, { @param.to_s => @param.to_s })
            filtered[@param.to_s] == '[FILTERED]'
          end

      end

      # Checks if the controller filters the given params.
      #
      # == Examples
      #
      #   should_filter_params :password
      #   should_not_filter_params :username
      #
      #   it { should filter_params(:password) }
      #   it { should_not filter_params(:username) }
      #
      def filter_params(*params, &block)
        FilterParamsMatcher.new(*params, &block).spec(self)
      end
      alias :filter_param :filter_params

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
remarkable_rails-3.1.7 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.8 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.0.10 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.3 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.0.9 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.0 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.1 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.2 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.5 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.4 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.6 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb