radar 0.2.0 → 0.3.0

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.
Files changed (39) hide show
  1. data/.yardopts +1 -0
  2. data/CHANGELOG.md +14 -1
  3. data/Gemfile +10 -4
  4. data/Gemfile.lock +65 -1
  5. data/README.md +10 -1
  6. data/docs/user_guide.md +214 -18
  7. data/examples/README.md +5 -0
  8. data/examples/rack/README.md +15 -0
  9. data/examples/rack/config.ru +18 -0
  10. data/lib/radar.rb +20 -2
  11. data/lib/radar/application.rb +30 -1
  12. data/lib/radar/config.rb +54 -12
  13. data/lib/radar/data_extensions/rack.rb +72 -0
  14. data/lib/radar/error.rb +1 -0
  15. data/lib/radar/exception_event.rb +6 -4
  16. data/lib/radar/filters/key_filter.rb +54 -0
  17. data/lib/radar/integration/rack.rb +41 -0
  18. data/lib/radar/integration/rails3.rb +19 -0
  19. data/lib/radar/integration/rails3/generator.rb +19 -0
  20. data/lib/radar/integration/rails3/railtie.rb +12 -0
  21. data/lib/radar/integration/rails3/templates/README +17 -0
  22. data/lib/radar/integration/rails3/templates/radar.rb +15 -0
  23. data/lib/radar/logger.rb +37 -0
  24. data/lib/radar/reporter/file_reporter.rb +31 -12
  25. data/lib/radar/reporter/io_reporter.rb +35 -0
  26. data/lib/radar/reporter/logger_reporter.rb +31 -0
  27. data/lib/radar/version.rb +1 -1
  28. data/radar.gemspec +2 -4
  29. data/test/radar/application_test.rb +38 -0
  30. data/test/radar/config_test.rb +34 -0
  31. data/test/radar/data_extensions/rack_test.rb +51 -0
  32. data/test/radar/exception_event_test.rb +20 -0
  33. data/test/radar/filters/key_filter_test.rb +28 -0
  34. data/test/radar/integration/rack_test.rb +61 -0
  35. data/test/radar/integration/rails3_test.rb +29 -0
  36. data/test/radar/logger_test.rb +13 -0
  37. data/test/radar/reporter/io_reporter_test.rb +20 -0
  38. data/test/radar/reporter/logger_reporter_test.rb +21 -0
  39. metadata +25 -4
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class KeyFilterTest < Test::Unit::TestCase
4
+ context "key filter class" do
5
+ setup do
6
+ @klass = Radar::Filters::KeyFilter
7
+ end
8
+
9
+ should "filter out the given key" do
10
+ @instance = @klass.new(:key => :password)
11
+ data = { :request => { :password => "foo" },
12
+ :rack_env => { :params => { "password" => "foo" } } }
13
+
14
+ result = @instance.filter(data)
15
+ assert_equal @instance.filter_text, data[:request][:password]
16
+ assert_equal @instance.filter_text, data[:rack_env][:params]["password"]
17
+ end
18
+
19
+ should "filter out multiple keys" do
20
+ @instance = @klass.new(:key => [:password, :username])
21
+ data = { :request => { :username => "foo", :password => "foo" } }
22
+
23
+ result = @instance.filter(data)
24
+ assert_equal @instance.filter_text, data[:request][:username]
25
+ assert_equal @instance.filter_text, data[:request][:password]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,61 @@
1
+ require 'test_helper'
2
+
3
+ class RackIntegrationTest < Test::Unit::TestCase
4
+ context "rack integration class" do
5
+ setup do
6
+ @klass = Radar::Integration::Rack
7
+ end
8
+
9
+ should "not allow integration via the actual integration test" do
10
+ assert_raises(RuntimeError) {
11
+ @klass.integrate!(nil)
12
+ }
13
+ end
14
+ end
15
+
16
+ context "rack middleware" do
17
+ setup do
18
+ require 'rack'
19
+ @klass = Rack::Radar
20
+ @rack_app = mock("rack_app")
21
+ @application = Radar::Application.new(:app, false)
22
+ end
23
+
24
+ should "raise an exception if no application is specified" do
25
+ assert_raises(ArgumentError) {
26
+ @klass.new(@rack_app)
27
+ }
28
+ end
29
+
30
+ should "raise an exception if invalid application is specified" do
31
+ assert_raises(ArgumentError) {
32
+ @klass.new(@rack_app, :application => 7)
33
+ }
34
+ end
35
+
36
+ should "enable the rack data extension" do
37
+ @klass.new(@rack_app, :application => @application)
38
+ assert @application.config.data_extensions.values.include?(Radar::DataExtensions::Rack)
39
+ end
40
+
41
+ should "call the next middleware properly" do
42
+ @rack_app.expects(:call).returns(:result)
43
+ assert_equal :result, @klass.new(@rack_app, :application => @application).call({})
44
+ end
45
+
46
+ should "report and reraise any exceptions raised" do
47
+ @rack_app.expects(:call).raises(RuntimeError)
48
+ @application.expects(:report).with() do |exception, extra|
49
+ assert exception.is_a?(RuntimeError)
50
+ assert extra[:rack_request]
51
+ assert extra[:rack_env]
52
+ assert_equal({:foo => :bar}, extra[:rack_env])
53
+ true
54
+ end
55
+
56
+ assert_raises(RuntimeError) {
57
+ @klass.new(@rack_app, :application => @application).call(:foo => :bar)
58
+ }
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+ require 'rails'
3
+
4
+ class Rails3IntegrationTest < Test::Unit::TestCase
5
+ context "rails3 integration class" do
6
+ setup do
7
+ @klass = Radar::Integration::Rails3
8
+ @app = Radar::Application.new(:app, false)
9
+ end
10
+
11
+ teardown do
12
+ # HACK I don't think rails was ever intended to work this way,
13
+ # but I'm able to clear out the application using this.
14
+ Rails.application = nil
15
+ end
16
+
17
+ should "raise an argument error if an application is not specified" do
18
+ assert_raises(ArgumentError) { @klass.integrate!(@app) }
19
+ end
20
+
21
+ should "integrate with a rails application" do
22
+ # NOTE This test used to actually initialize the rails application
23
+ # but it was creating a `log/` directory in the toplevel which was
24
+ # pretty annoying. So this suffices for now.
25
+ rails_app = Class.new(Rails::Application)
26
+ assert_nothing_raised { @klass.integrate!(@app) }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class LoggerTest < Test::Unit::TestCase
4
+ context "logger class" do
5
+ setup do
6
+ @klass = Radar::Logger
7
+ end
8
+
9
+ should "return true, temporarily" do
10
+ assert true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class IoReporterTest < Test::Unit::TestCase
4
+ context "io reporter class" do
5
+ setup do
6
+ @klass = Radar::Reporter::IoReporter
7
+ end
8
+
9
+ should "be fine if no io_object is given" do
10
+ assert_nothing_raised {
11
+ @klass.new.report(create_exception_event)
12
+ }
13
+ end
14
+
15
+ should "raise an ArgumentError if a non-IO object is given" do
16
+ @instance = @klass.new :io_object => 7
17
+ assert_raises(ArgumentError) { @instance.report(create_exception_event) }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class LoggerReporterTest < Test::Unit::TestCase
4
+ context "logger reporter class" do
5
+ setup do
6
+ @klass = Radar::Reporter::LoggerReporter
7
+ end
8
+
9
+ should "raise an argument error if no logger is given" do
10
+ assert_raises(ArgumentError) { @klass.new.report(create_exception_event) }
11
+ end
12
+
13
+ should "raise an argument error if an invalid logger is given" do
14
+ assert_raises(ArgumentError) { @klass.new(:log_object => 7).report(create_exception_event) }
15
+ end
16
+
17
+ should "raise an argument error if the logger doesn't respond to the log level" do
18
+ assert_raises(ArgumentError) { @klass.new(:log_object => Logger.new(nil), :log_level => :bananas).report(create_exception_event) }
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mitchell Hashimoto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-17 00:00:00 -07:00
17
+ date: 2010-08-21 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -107,26 +107,47 @@ files:
107
107
  - README.md
108
108
  - Rakefile
109
109
  - docs/user_guide.md
110
+ - examples/README.md
111
+ - examples/rack/README.md
112
+ - examples/rack/config.ru
110
113
  - lib/radar.rb
111
114
  - lib/radar/application.rb
112
115
  - lib/radar/config.rb
113
116
  - lib/radar/data_extensions/host_environment.rb
117
+ - lib/radar/data_extensions/rack.rb
114
118
  - lib/radar/error.rb
115
119
  - lib/radar/exception_event.rb
120
+ - lib/radar/filters/key_filter.rb
121
+ - lib/radar/integration/rack.rb
122
+ - lib/radar/integration/rails3.rb
123
+ - lib/radar/integration/rails3/generator.rb
124
+ - lib/radar/integration/rails3/railtie.rb
125
+ - lib/radar/integration/rails3/templates/README
126
+ - lib/radar/integration/rails3/templates/radar.rb
127
+ - lib/radar/logger.rb
116
128
  - lib/radar/matchers/backtrace_matcher.rb
117
129
  - lib/radar/matchers/class_matcher.rb
118
130
  - lib/radar/reporter.rb
119
131
  - lib/radar/reporter/file_reporter.rb
132
+ - lib/radar/reporter/io_reporter.rb
133
+ - lib/radar/reporter/logger_reporter.rb
120
134
  - lib/radar/support.rb
121
135
  - lib/radar/version.rb
122
136
  - radar.gemspec
123
137
  - test/radar/application_test.rb
124
138
  - test/radar/config_test.rb
125
139
  - test/radar/data_extensions/host_environment_test.rb
140
+ - test/radar/data_extensions/rack_test.rb
126
141
  - test/radar/exception_event_test.rb
142
+ - test/radar/filters/key_filter_test.rb
143
+ - test/radar/integration/rack_test.rb
144
+ - test/radar/integration/rails3_test.rb
145
+ - test/radar/logger_test.rb
127
146
  - test/radar/matchers/backtrace_matcher_test.rb
128
147
  - test/radar/matchers/class_matcher_test.rb
129
148
  - test/radar/reporter/file_reporter_test.rb
149
+ - test/radar/reporter/io_reporter_test.rb
150
+ - test/radar/reporter/logger_reporter_test.rb
130
151
  - test/radar/reporter_test.rb
131
152
  - test/radar/support_test.rb
132
153
  - test/test_helper.rb
@@ -144,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
165
  requirements:
145
166
  - - ">="
146
167
  - !ruby/object:Gem::Version
147
- hash: -4581519538816896341
168
+ hash: -3089432238801880584
148
169
  segments:
149
170
  - 0
150
171
  version: "0"