Sha256: e104761313644758e9d89a485fbf4f183431ca675d78695b5f2e5eb03a486713

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

class ToadHopper::TestFilters < Test::Unit::TestCase
  def toadhopper
    @toadhopper ||= ToadHopper.new("test api key")
  end
  
  def test_no_filters
    assert_equal(                {:id => "myid", :password => "mypassword"},
                 toadhopper.clean(:id => "myid", :password => "mypassword"))
  end

  def test_string_filter
    toadhopper.filters = "pass"
    assert_equal(                {:id => "myid", :password => "[FILTERED]"},
                 toadhopper.clean(:id => "myid", :password => "mypassword"))
  end

  def test_regex_filter
    toadhopper.filters = /pas{2}/
    assert_equal(                {:id => "myid", :password => "[FILTERED]"},
                 toadhopper.clean(:id => "myid", :password => "mypassword"))
  end

  def test_multiple_filters
    toadhopper.filters = "email", /pas{2}/
    assert_equal(                 {:id => "myid", :email => "[FILTERED]", :password => "[FILTERED]"},
                 toadhopper.clean(:id => "myid", :email => "myemail", :password => "mypassword"))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
toadhopper-0.9.2 test/test_filters.rb
toadhopper-0.9.1 test/test_filters.rb
toadhopper-0.9 test/test_filters.rb