raygun4ruby 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -18
  3. data/.rspec +1 -1
  4. data/.travis.yml +20 -20
  5. data/CHANGELOG.md +127 -124
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +22 -22
  8. data/README.md +420 -420
  9. data/Rakefile +27 -27
  10. data/examples/sinatras_raygun.rb +17 -17
  11. data/lib/generators/raygun/install_generator.rb +26 -26
  12. data/lib/raygun.rb +179 -179
  13. data/lib/raygun/affected_user.rb +59 -59
  14. data/lib/raygun/breadcrumbs.rb +34 -34
  15. data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
  16. data/lib/raygun/breadcrumbs/store.rb +86 -86
  17. data/lib/raygun/client.rb +305 -305
  18. data/lib/raygun/configuration.rb +194 -194
  19. data/lib/raygun/error.rb +10 -10
  20. data/lib/raygun/javascript_tracker.rb +42 -42
  21. data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
  22. data/lib/raygun/middleware/javascript_exception_tracking.rb +32 -32
  23. data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
  24. data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
  25. data/lib/raygun/railtie.rb +39 -39
  26. data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
  27. data/lib/raygun/sidekiq.rb +71 -70
  28. data/lib/raygun/testable.rb +22 -22
  29. data/lib/raygun/version.rb +3 -3
  30. data/lib/raygun4ruby.rb +1 -1
  31. data/lib/resque/failure/raygun.rb +25 -25
  32. data/lib/tasks/raygun.tasks +7 -7
  33. data/raygun4ruby.gemspec +45 -45
  34. data/spec/dummy/.gitignore +17 -17
  35. data/spec/dummy/Gemfile +47 -47
  36. data/spec/dummy/README.rdoc +28 -28
  37. data/spec/dummy/Rakefile +6 -6
  38. data/spec/dummy/app/assets/config/manifest.js +2 -2
  39. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  40. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  41. data/spec/dummy/app/controllers/application_controller.rb +5 -5
  42. data/spec/dummy/app/controllers/home_controller.rb +4 -4
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  44. data/spec/dummy/app/views/home/index.html.erb +3 -3
  45. data/spec/dummy/app/views/home/index.json.erb +1 -1
  46. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  47. data/spec/dummy/bin/bundle +3 -3
  48. data/spec/dummy/bin/rails +9 -9
  49. data/spec/dummy/bin/rake +9 -9
  50. data/spec/dummy/bin/setup +29 -29
  51. data/spec/dummy/bin/spring +17 -17
  52. data/spec/dummy/config.ru +4 -4
  53. data/spec/dummy/config/application.rb +26 -26
  54. data/spec/dummy/config/boot.rb +3 -3
  55. data/spec/dummy/config/database.yml +25 -25
  56. data/spec/dummy/config/environment.rb +5 -5
  57. data/spec/dummy/config/environments/development.rb +41 -41
  58. data/spec/dummy/config/environments/production.rb +79 -79
  59. data/spec/dummy/config/environments/test.rb +42 -42
  60. data/spec/dummy/config/initializers/assets.rb +11 -11
  61. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  62. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -3
  63. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  64. data/spec/dummy/config/initializers/inflections.rb +16 -16
  65. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  66. data/spec/dummy/config/initializers/session_store.rb +3 -3
  67. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -10
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  69. data/spec/dummy/config/locales/en.yml +23 -23
  70. data/spec/dummy/config/routes.rb +58 -58
  71. data/spec/dummy/config/secrets.yml +22 -22
  72. data/spec/dummy/db/seeds.rb +7 -7
  73. data/spec/dummy/public/404.html +67 -67
  74. data/spec/dummy/public/422.html +67 -67
  75. data/spec/dummy/public/500.html +66 -66
  76. data/spec/dummy/public/robots.txt +5 -5
  77. data/spec/dummy/test/test_helper.rb +10 -10
  78. data/spec/features/javascript_spec.rb +48 -48
  79. data/spec/rails_helper.rb +4 -4
  80. data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
  81. data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
  82. data/spec/raygun/raygun_spec.rb +47 -47
  83. data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
  84. data/spec/spec_helper.rb +24 -24
  85. data/spec/support/fake_logger.rb +17 -17
  86. data/test/integration/client_test.rb +19 -19
  87. data/test/test_helper.rb +72 -72
  88. data/test/unit/affected_user_test.rb +136 -136
  89. data/test/unit/client_test.rb +792 -792
  90. data/test/unit/configuration_test.rb +206 -206
  91. data/test/unit/raygun_test.rb +25 -25
  92. data/test/unit/resque_failure_test.rb +24 -24
  93. data/test/unit/sidekiq_failure_test.rb +32 -32
  94. metadata +7 -7
@@ -1,206 +1,206 @@
1
- require_relative "../test_helper.rb"
2
-
3
- class ConfigurationTest < Raygun::UnitTest
4
-
5
- class TestException < StandardError; end
6
- class Test2Exception < StandardError; end
7
-
8
- def setup
9
- Raygun.setup do |config|
10
- config.api_key = "a test api key"
11
- config.version = 9.9
12
- end
13
- end
14
-
15
- def teardown
16
- Raygun.reset_configuration
17
- end
18
-
19
- def test_setting_api_key_and_version
20
- assert_equal 9.9, Raygun.configuration.version
21
- assert_equal "a test api key", Raygun.configuration.api_key
22
- end
23
-
24
- def test_hash_style_access
25
- assert_equal 9.9, Raygun.configuration[:version]
26
- end
27
-
28
- def test_set_js_api_key
29
- Raygun.configuration.js_api_key = "a test js api key"
30
-
31
- assert_equal "a test js api key", Raygun.configuration.js_api_key
32
- end
33
-
34
- def test_set_js_api_version
35
- Raygun.configuration.js_api_version = "a test js api version"
36
-
37
- assert_equal "a test js api version", Raygun.configuration.js_api_version
38
- end
39
-
40
- def test_enable_reporting
41
- Raygun.configuration.enable_reporting = false
42
-
43
- # should be no API call
44
- assert_nil Raygun.track_exception(TestException.new)
45
- end
46
-
47
- def test_silence_reporting
48
- Raygun.configuration.silence_reporting = true
49
-
50
- # nothing returned as there's no HTTP call
51
- assert_nil Raygun.track_exception(TestException.new)
52
- end
53
-
54
- def test_ignoring_exceptions
55
- Raygun.configuration.ignore << TestException.to_s
56
-
57
- assert_nil Raygun.track_exception(TestException.new)
58
- end
59
-
60
- def test_ignoring_multiple_exceptions
61
- Raygun.configuration.ignore << [TestException.to_s, Test2Exception.to_s]
62
-
63
- assert_nil Raygun.track_exception(TestException.new)
64
- assert_nil Raygun.track_exception(Test2Exception.new)
65
- end
66
-
67
- def test_default_values
68
- assert_equal({}, Raygun.configuration.custom_data)
69
- end
70
-
71
- def test_default_tags_set
72
- assert_equal([], Raygun.configuration.tags)
73
- end
74
-
75
- def test_overriding_defaults
76
- Raygun.default_configuration.custom_data = { robby: "robot" }
77
- assert_equal({ robby: "robot" }, Raygun.configuration.custom_data)
78
-
79
- Raygun.configuration.custom_data = { sally: "stegosaurus" }
80
- assert_equal({ sally: "stegosaurus" }, Raygun.configuration.custom_data)
81
- end
82
-
83
- def test_debug
84
- Raygun.setup do |config|
85
- config.debug = true
86
- end
87
-
88
- assert_equal Raygun.configuration.debug, true
89
- end
90
-
91
- def test_debug_default_set
92
- assert_equal false, Raygun.configuration.debug
93
- end
94
-
95
- def test_setting_filter_paramters_to_proc
96
- Raygun.setup do |config|
97
- config.filter_parameters do |hash|
98
- # Don't need to do anything :)
99
- end
100
- end
101
-
102
- assert Raygun.configuration.filter_parameters.is_a?(Proc)
103
- ensure
104
- Raygun.configuration.filter_parameters = nil
105
- end
106
-
107
- def test_filter_payload_with_whitelist_default
108
- assert_equal(false, Raygun.configuration.filter_payload_with_whitelist)
109
- end
110
-
111
- def test_setting_whitelist_payload_keys_to_proc
112
- Raygun.setup do |config|
113
- config.whitelist_payload_shape do |hash|
114
- # No-op
115
- end
116
- end
117
-
118
- assert Raygun.configuration.whitelist_payload_shape.is_a?(Proc)
119
- ensure
120
- Raygun.configuration.whitelist_payload_shape = nil
121
- end
122
-
123
- def test_setting_custom_data_to_proc
124
- Raygun.setup do |config|
125
- config.custom_data do |exception, env|
126
- # No-op
127
- end
128
- end
129
-
130
- assert Raygun.configuration.custom_data.is_a?(Proc)
131
- ensure
132
- Raygun.configuration.custom_data = nil
133
- end
134
-
135
- def test_setting_custom_data_to_hash
136
- Raygun.setup do |config|
137
- config.custom_data = {}
138
- end
139
-
140
- assert Raygun.configuration.custom_data.is_a?(Hash)
141
- ensure
142
- Raygun.configuration.custom_data = nil
143
- end
144
-
145
- def test_setting_tags_to_array
146
- Raygun.setup do |c|
147
- c.tags = ['test']
148
- end
149
-
150
- assert_equal Raygun.configuration.tags, ['test']
151
- end
152
-
153
- def test_setting_tags_to_proc
154
- Raygun.setup do |c|
155
- c.tags = ->(exception, env) {}
156
- end
157
-
158
- assert Raygun.configuration.tags.is_a?(Proc)
159
- end
160
-
161
- def test_api_url_default
162
- assert_equal "https://api.raygun.io/", Raygun.configuration.api_url
163
- end
164
-
165
- def test_setting_breadcrumb_level
166
- Raygun.setup do |config|
167
- config.breadcrumb_level = :info
168
- end
169
-
170
- assert_equal :info, Raygun.configuration.breadcrumb_level
171
- end
172
-
173
- def test_setting_breadcrumb_level_to_bad_value
174
- logger = setup_logging
175
-
176
- Raygun.setup do |config|
177
- config.breadcrumb_level = :invalid
178
- end
179
-
180
- assert_equal :info, Raygun.configuration.breadcrumb_level
181
- assert(
182
- logger.get.include?("unknown breadcrumb level"),
183
- "unknown breadcrumb level message was not logged"
184
- )
185
- end
186
-
187
- def test_breadcrumb_level_default
188
- assert_equal :info, Raygun.configuration.breadcrumb_level
189
- end
190
-
191
- def test_record_raw_data_default
192
- assert_equal false, Raygun.configuration.record_raw_data
193
- end
194
-
195
- def test_send_in_background_default
196
- assert_equal false, Raygun.configuration.send_in_background
197
- end
198
-
199
- def test_error_report_send_timeout_default
200
- assert_equal 10, Raygun.configuration.error_report_send_timeout
201
- end
202
-
203
- def test_enable_reporting_default
204
- assert_equal true, Raygun.configuration.enable_reporting
205
- end
206
- end
1
+ require_relative "../test_helper.rb"
2
+
3
+ class ConfigurationTest < Raygun::UnitTest
4
+
5
+ class TestException < StandardError; end
6
+ class Test2Exception < StandardError; end
7
+
8
+ def setup
9
+ Raygun.setup do |config|
10
+ config.api_key = "a test api key"
11
+ config.version = 9.9
12
+ end
13
+ end
14
+
15
+ def teardown
16
+ Raygun.reset_configuration
17
+ end
18
+
19
+ def test_setting_api_key_and_version
20
+ assert_equal 9.9, Raygun.configuration.version
21
+ assert_equal "a test api key", Raygun.configuration.api_key
22
+ end
23
+
24
+ def test_hash_style_access
25
+ assert_equal 9.9, Raygun.configuration[:version]
26
+ end
27
+
28
+ def test_set_js_api_key
29
+ Raygun.configuration.js_api_key = "a test js api key"
30
+
31
+ assert_equal "a test js api key", Raygun.configuration.js_api_key
32
+ end
33
+
34
+ def test_set_js_api_version
35
+ Raygun.configuration.js_api_version = "a test js api version"
36
+
37
+ assert_equal "a test js api version", Raygun.configuration.js_api_version
38
+ end
39
+
40
+ def test_enable_reporting
41
+ Raygun.configuration.enable_reporting = false
42
+
43
+ # should be no API call
44
+ assert_nil Raygun.track_exception(TestException.new)
45
+ end
46
+
47
+ def test_silence_reporting
48
+ Raygun.configuration.silence_reporting = true
49
+
50
+ # nothing returned as there's no HTTP call
51
+ assert_nil Raygun.track_exception(TestException.new)
52
+ end
53
+
54
+ def test_ignoring_exceptions
55
+ Raygun.configuration.ignore << TestException.to_s
56
+
57
+ assert_nil Raygun.track_exception(TestException.new)
58
+ end
59
+
60
+ def test_ignoring_multiple_exceptions
61
+ Raygun.configuration.ignore << [TestException.to_s, Test2Exception.to_s]
62
+
63
+ assert_nil Raygun.track_exception(TestException.new)
64
+ assert_nil Raygun.track_exception(Test2Exception.new)
65
+ end
66
+
67
+ def test_default_values
68
+ assert_equal({}, Raygun.configuration.custom_data)
69
+ end
70
+
71
+ def test_default_tags_set
72
+ assert_equal([], Raygun.configuration.tags)
73
+ end
74
+
75
+ def test_overriding_defaults
76
+ Raygun.default_configuration.custom_data = { robby: "robot" }
77
+ assert_equal({ robby: "robot" }, Raygun.configuration.custom_data)
78
+
79
+ Raygun.configuration.custom_data = { sally: "stegosaurus" }
80
+ assert_equal({ sally: "stegosaurus" }, Raygun.configuration.custom_data)
81
+ end
82
+
83
+ def test_debug
84
+ Raygun.setup do |config|
85
+ config.debug = true
86
+ end
87
+
88
+ assert_equal Raygun.configuration.debug, true
89
+ end
90
+
91
+ def test_debug_default_set
92
+ assert_equal false, Raygun.configuration.debug
93
+ end
94
+
95
+ def test_setting_filter_paramters_to_proc
96
+ Raygun.setup do |config|
97
+ config.filter_parameters do |hash|
98
+ # Don't need to do anything :)
99
+ end
100
+ end
101
+
102
+ assert Raygun.configuration.filter_parameters.is_a?(Proc)
103
+ ensure
104
+ Raygun.configuration.filter_parameters = nil
105
+ end
106
+
107
+ def test_filter_payload_with_whitelist_default
108
+ assert_equal(false, Raygun.configuration.filter_payload_with_whitelist)
109
+ end
110
+
111
+ def test_setting_whitelist_payload_keys_to_proc
112
+ Raygun.setup do |config|
113
+ config.whitelist_payload_shape do |hash|
114
+ # No-op
115
+ end
116
+ end
117
+
118
+ assert Raygun.configuration.whitelist_payload_shape.is_a?(Proc)
119
+ ensure
120
+ Raygun.configuration.whitelist_payload_shape = nil
121
+ end
122
+
123
+ def test_setting_custom_data_to_proc
124
+ Raygun.setup do |config|
125
+ config.custom_data do |exception, env|
126
+ # No-op
127
+ end
128
+ end
129
+
130
+ assert Raygun.configuration.custom_data.is_a?(Proc)
131
+ ensure
132
+ Raygun.configuration.custom_data = nil
133
+ end
134
+
135
+ def test_setting_custom_data_to_hash
136
+ Raygun.setup do |config|
137
+ config.custom_data = {}
138
+ end
139
+
140
+ assert Raygun.configuration.custom_data.is_a?(Hash)
141
+ ensure
142
+ Raygun.configuration.custom_data = nil
143
+ end
144
+
145
+ def test_setting_tags_to_array
146
+ Raygun.setup do |c|
147
+ c.tags = ['test']
148
+ end
149
+
150
+ assert_equal Raygun.configuration.tags, ['test']
151
+ end
152
+
153
+ def test_setting_tags_to_proc
154
+ Raygun.setup do |c|
155
+ c.tags = ->(exception, env) {}
156
+ end
157
+
158
+ assert Raygun.configuration.tags.is_a?(Proc)
159
+ end
160
+
161
+ def test_api_url_default
162
+ assert_equal "https://api.raygun.com/", Raygun.configuration.api_url
163
+ end
164
+
165
+ def test_setting_breadcrumb_level
166
+ Raygun.setup do |config|
167
+ config.breadcrumb_level = :info
168
+ end
169
+
170
+ assert_equal :info, Raygun.configuration.breadcrumb_level
171
+ end
172
+
173
+ def test_setting_breadcrumb_level_to_bad_value
174
+ logger = setup_logging
175
+
176
+ Raygun.setup do |config|
177
+ config.breadcrumb_level = :invalid
178
+ end
179
+
180
+ assert_equal :info, Raygun.configuration.breadcrumb_level
181
+ assert(
182
+ logger.get.include?("unknown breadcrumb level"),
183
+ "unknown breadcrumb level message was not logged"
184
+ )
185
+ end
186
+
187
+ def test_breadcrumb_level_default
188
+ assert_equal :info, Raygun.configuration.breadcrumb_level
189
+ end
190
+
191
+ def test_record_raw_data_default
192
+ assert_equal false, Raygun.configuration.record_raw_data
193
+ end
194
+
195
+ def test_send_in_background_default
196
+ assert_equal false, Raygun.configuration.send_in_background
197
+ end
198
+
199
+ def test_error_report_send_timeout_default
200
+ assert_equal 10, Raygun.configuration.error_report_send_timeout
201
+ end
202
+
203
+ def test_enable_reporting_default
204
+ assert_equal true, Raygun.configuration.enable_reporting
205
+ end
206
+ end
@@ -1,25 +1,25 @@
1
- # -*- coding: utf-8 -*-
2
- require_relative "../test_helper.rb"
3
-
4
- class RaygunTest < Raygun::UnitTest
5
- def test_raygun_is_not_configured_with_no_api_key
6
- Raygun.configuration.api_key = nil
7
- assert !Raygun.configured?
8
- end
9
-
10
- def test_should_report_logs_silence_reporting_when_debug_is_on
11
- logger = setup_logging
12
- Raygun.configuration.silence_reporting = true
13
- Raygun.send(:should_report?, Exception.new)
14
-
15
- assert logger.get.include?("silence_reporting"), "silence_reporting was not logged"
16
- end
17
-
18
- def test_should_report_logs_ignored_exceptions_when_debug_is_on
19
- logger = setup_logging
20
- Raygun.configuration.ignore = ["Exception"]
21
- Raygun.send(:should_report?, Exception.new)
22
-
23
- assert logger.get =~ /skipping reporting of.*Exception.*/, "ignored exception was not logged"
24
- end
25
- end
1
+ # -*- coding: utf-8 -*-
2
+ require_relative "../test_helper.rb"
3
+
4
+ class RaygunTest < Raygun::UnitTest
5
+ def test_raygun_is_not_configured_with_no_api_key
6
+ Raygun.configuration.api_key = nil
7
+ assert !Raygun.configured?
8
+ end
9
+
10
+ def test_should_report_logs_silence_reporting_when_debug_is_on
11
+ logger = setup_logging
12
+ Raygun.configuration.silence_reporting = true
13
+ Raygun.send(:should_report?, Exception.new)
14
+
15
+ assert logger.get.include?("silence_reporting"), "silence_reporting was not logged"
16
+ end
17
+
18
+ def test_should_report_logs_ignored_exceptions_when_debug_is_on
19
+ logger = setup_logging
20
+ Raygun.configuration.ignore = ["Exception"]
21
+ Raygun.send(:should_report?, Exception.new)
22
+
23
+ assert logger.get =~ /skipping reporting of.*Exception.*/, "ignored exception was not logged"
24
+ end
25
+ end