<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe 'filter_params' do
  include FunctionalBuilder

  describe 'messages' do
    before(:each) do
      @controller = define_controller :Projects do
        filter_parameter_logging :password
      end.new

      @matcher = filter_params(:user)
    end

    it 'should contain a description message' do
      @matcher.description.should == 'filter parameters user from log'
    end

    it 'should set respond_to_filter_params? message' do
      @controller.class_eval "undef_method :filter_parameters"
      @matcher.matches?(@controller)
      @matcher.failure_message.should == 'Expected controller to respond to filter_parameters (controller is not filtering any parameter)'
    end

    it 'should set is_filtered? message' do
      @matcher.matches?(@controller)
      @matcher.failure_message.should == 'Expected user to be filtered'
    end
  end

  describe 'filtering parameter' do
    before(:each) do 
      @controller = define_controller :Projects do
        filter_parameter_logging :password
      end.new

      self.class.subject { @controller }
    end

    should_filter_params
    should_filter_params(:password)
    should_not_filter_params(:user)

    it { should filter_params }
    it { should filter_params(:password) }
    it { should_not filter_params(:user) }
  end

  describe 'not filtering parameter' do
    before(:each) do 
      @controller = define_controller(:Projects).new

      self.class.subject { @controller }
    end

    should_not_filter_params
    should_not_filter_params(:password)
    should_not_filter_params(:user)

    it { should_not filter_params }
    it { should_not filter_params(:user) }
    it { should_not filter_params(:password) }
  end

end<commit_msg>remarkable_rails specs now passing on Rails 2.1.2, 2.2.2 and 2.3.2<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe 'filter_params' do
  include FunctionalBuilder

  describe 'messages' do
    before(:each) do
      @controller = define_controller :Posts do
        filter_parameter_logging :password
      end.new

      @matcher = filter_params(:user)
    end

    it 'should contain a description message' do
      @matcher.description.should == 'filter parameters user from log'
    end

    it 'should set respond_to_filter_params? message' do
      @controller = define_controller(:Comments).new
      @matcher.matches?(@controller)
      @matcher.failure_message.should == 'Expected controller to respond to filter_parameters (controller is not filtering any parameter)'
    end

    it 'should set is_filtered? message' do
      @matcher.matches?(@controller)
      @matcher.failure_message.should == 'Expected user to be filtered'
    end
  end

  describe 'filtering parameter' do
    before(:each) do 
      @controller = define_controller :Comments do
        filter_parameter_logging :password
      end.new

      self.class.subject { @controller }
    end

    should_filter_params
    should_filter_params(:password)
    should_not_filter_params(:user)

    it { should filter_params }
    it { should filter_params(:password) }
    it { should_not filter_params(:user) }
  end

  describe 'not filtering parameter' do
    before(:each) do 
      @controller = define_controller(:Comments).new
      self.class.subject { @controller }
    end

    should_not_filter_params
    should_not_filter_params(:password)
    should_not_filter_params(:user)

    it { should_not filter_params }
    it { should_not filter_params(:user) }
    it { should_not filter_params(:password) }
  end

end
{'fraction_non_alphanumeric': 0.08326485894275541, 'fraction_numerical': 0.0024650780608052587, 'mean_word_length': 3.4482338611449452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5452649', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1013, 'n_words': 269}