toadhopper 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/toadhopper.rb CHANGED
@@ -4,7 +4,8 @@ require 'ostruct'
4
4
 
5
5
  # Posts errors to the Hoptoad API
6
6
  class Toadhopper
7
- VERSION = "1.0.2"
7
+ VERSION = "1.0.3"
8
+ FILTER_REPLACEMENT = "[FILTERED]"
8
9
 
9
10
  # Hoptoad API response
10
11
  class Response < Struct.new(:status, :body, :errors); end
@@ -123,7 +124,7 @@ class Toadhopper
123
124
 
124
125
  def filtered_value(key, value)
125
126
  if filters.any? {|f| key.to_s =~ Regexp.new(f)}
126
- "[FILTERED]"
127
+ FILTER_REPLACEMENT
127
128
  else
128
129
  value
129
130
  end
data/test/helper.rb CHANGED
@@ -2,8 +2,7 @@ Bundler.setup(:test)
2
2
  Bundler.require(:test)
3
3
 
4
4
  require 'test/unit'
5
-
6
- require File.expand_path("../../lib/toadhopper", __FILE__)
5
+ require "toadhopper"
7
6
 
8
7
  def toadhopper
9
8
  @toadhopper ||= Toadhopper.new(ENV['HOPTOAD_API_KEY'] || "test api key")
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class Toadhopper::TestConvenienceConstructor < Test::Unit::TestCase
4
+ def test_convenience_constructor
5
+ assert_kind_of Toadhopper, Toadhopper.new('somekey')
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class Toadhopper::TestFiltering < Test::Unit::TestCase
4
+ def test_filtering
5
+ assert_not_filtered "safe", "sensitive"
6
+ assert_not_filtered "safe", /sensitive/
7
+ assert_filtered "sensitive", "sensitive"
8
+ assert_filtered "sensitive", /sensitive/
9
+ assert_filtered "sensitive", /sit/
10
+ end
11
+
12
+ def assert_not_filtered(key, filter)
13
+ assert_false filtered_document(key, "value", filter).include?(Toadhopper::FILTER_REPLACEMENT)
14
+ end
15
+
16
+ def assert_filtered(key, filter)
17
+ assert_false filtered_document(key, "value", filter).include?("value")
18
+ end
19
+
20
+ def filtered_document(key, value, filter)
21
+ toadhopper.filters = filter
22
+ hash = {"nested" => {key => value}, key => value}
23
+ toadhopper.__send__(:document_for, error, {:params => hash, :session => hash, :environment => hash})
24
+ end
25
+ end
data/test/test_posting.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
1
+ require 'helper'
2
2
 
3
3
  class Toadhopper::TestPosting < Test::Unit::TestCase
4
4
  def test_posting
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toadhopper
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 2
9
- version: 1.0.2
4
+ version: 1.0.3
10
5
  platform: ruby
11
6
  authors:
12
7
  - Tim Lucas
@@ -17,7 +12,7 @@ autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
14
 
20
- date: 2010-03-24 00:00:00 -07:00
15
+ date: 2010-04-01 00:00:00 +11:00
21
16
  default_executable:
22
17
  dependencies: []
23
18
 
@@ -40,8 +35,8 @@ files:
40
35
  - lib/notice.erb
41
36
  - lib/toadhopper.rb
42
37
  - test/helper.rb
43
- - test/test_filters.rb
44
- - test/test_notice_document_data.rb
38
+ - test/test_convenience_constructor.rb
39
+ - test/test_filtering.rb
45
40
  - test/test_posting.rb
46
41
  has_rdoc: true
47
42
  homepage: http://github.com/toolmantim/toadhopper
@@ -56,25 +51,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
51
  requirements:
57
52
  - - ">="
58
53
  - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
54
  version: "0"
55
+ version:
62
56
  required_rubygems_version: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - ">="
65
59
  - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
60
  version: "0"
61
+ version:
69
62
  requirements: []
70
63
 
71
64
  rubyforge_project:
72
- rubygems_version: 1.3.6
65
+ rubygems_version: 1.3.5
73
66
  signing_key:
74
67
  specification_version: 3
75
68
  summary: Post error notifications to Hoptoad
76
69
  test_files:
77
70
  - test/helper.rb
78
- - test/test_filters.rb
79
- - test/test_notice_document_data.rb
71
+ - test/test_convenience_constructor.rb
72
+ - test/test_filtering.rb
80
73
  - test/test_posting.rb
data/test/test_filters.rb DELETED
@@ -1,26 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- class Toadhopper::TestFilters < Test::Unit::TestCase
4
- def test_no_filters
5
- assert_equal( {:id => "myid", :password => "mypassword"},
6
- toadhopper.clean(:id => "myid", :password => "mypassword"))
7
- end
8
-
9
- def test_string_filter
10
- toadhopper.filters = "pass"
11
- assert_equal( {:id => "myid", :password => "[FILTERED]"},
12
- toadhopper.clean(:id => "myid", :password => "mypassword"))
13
- end
14
-
15
- def test_regex_filter
16
- toadhopper.filters = /pas{2}/
17
- assert_equal( {:id => "myid", :password => "[FILTERED]"},
18
- toadhopper.clean(:id => "myid", :password => "mypassword"))
19
- end
20
-
21
- def test_multiple_filters
22
- toadhopper.filters = "email", /pas{2}/
23
- assert_equal( {:id => "myid", :email => "[FILTERED]", :password => "[FILTERED]"},
24
- toadhopper.clean(:id => "myid", :email => "myemail", :password => "mypassword"))
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- class Toadhopper::TestNoticeDocument < Test::Unit::TestCase
4
- def test_filtering
5
- toadhopper.filters = "password"
6
- sensitive_options = {
7
- :params => {"password" => "sensitive"},
8
- :session => {"password" => "sensitive"},
9
- :environment => {"password" => "sensitive"}
10
- }
11
- notice_document = toadhopper.document_for(error, sensitive_options)
12
- assert_false notice_document.include?("sensitive")
13
- end
14
- end