Sha256: 86c3833e0c82d1fa20c3b6a7adf1acde3d185f0799765d276f13c9c5cb872ae0

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

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

class ToadHopper::TestFilters < Test::Unit::TestCase
  def toadhopper
    @toadhopper ||= ToadHopper("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

4 entries across 4 versions & 2 rubygems

Version Path
gbuesing-toadhopper-0.3.0 test/test_filters.rb
gbuesing-toadhopper-0.2.0 test/test_filters.rb
gbuesing-toadhopper-0.1.0 test/test_filters.rb
toadhopper-0.9.4 test/test_filters.rb