Sha256: b191226043274313122abde4f47405157af65e63126da0d924871d3e24c76e21

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 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

9 entries across 9 versions & 2 rubygems

Version Path
benhutton-remarkable_rails-4.0.0.alpha7 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
benhutton-remarkable_rails-4.0.0.alpha6 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
benhutton-remarkable_rails-4.0.0.alpha5 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
benhutton-remarkable_rails-4.0.0.alpha4 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.13 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.12 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.11 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.10 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
remarkable_rails-3.1.9 lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb