rollbar 2.16.2 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +47 -0
  3. data/.travis.yml +182 -94
  4. data/Appraisals +10 -10
  5. data/Gemfile +45 -13
  6. data/README.md +20 -3
  7. data/Rakefile +0 -0
  8. data/data/rollbar.snippet.js +1 -1
  9. data/docs/configuration.md +15 -0
  10. data/gemfiles/rails30.gemfile +21 -14
  11. data/gemfiles/rails31.gemfile +21 -12
  12. data/gemfiles/rails32.gemfile +18 -8
  13. data/gemfiles/rails40.gemfile +18 -6
  14. data/gemfiles/rails41.gemfile +17 -6
  15. data/gemfiles/rails42.gemfile +24 -14
  16. data/gemfiles/rails50.gemfile +20 -11
  17. data/gemfiles/rails51.gemfile +20 -10
  18. data/gemfiles/rails52.gemfile +65 -0
  19. data/gemfiles/rails60.gemfile +67 -0
  20. data/lib/generators/rollbar/rollbar_generator.rb +1 -1
  21. data/lib/rails/rollbar_runner.rb +17 -2
  22. data/lib/rollbar.rb +2 -3
  23. data/lib/rollbar/capistrano.rb +71 -39
  24. data/lib/rollbar/capistrano3.rb +56 -1
  25. data/lib/rollbar/capistrano_tasks.rb +130 -0
  26. data/lib/rollbar/configuration.rb +95 -7
  27. data/lib/rollbar/delay/active_job.rb +17 -0
  28. data/lib/rollbar/delay/girl_friday.rb +2 -2
  29. data/lib/rollbar/delay/resque.rb +4 -6
  30. data/lib/rollbar/delay/shoryuken.rb +15 -9
  31. data/lib/rollbar/delay/sidekiq.rb +6 -8
  32. data/lib/rollbar/delay/sucker_punch.rb +17 -19
  33. data/lib/rollbar/delay/thread.rb +3 -3
  34. data/lib/rollbar/deploy.rb +90 -0
  35. data/lib/rollbar/encoding/encoder.rb +9 -9
  36. data/lib/rollbar/exception_reporter.rb +19 -5
  37. data/lib/rollbar/item.rb +62 -20
  38. data/lib/rollbar/item/backtrace.rb +4 -4
  39. data/lib/rollbar/item/frame.rb +7 -1
  40. data/lib/rollbar/item/locals.rb +56 -0
  41. data/lib/rollbar/json.rb +5 -51
  42. data/lib/rollbar/language_support.rb +4 -20
  43. data/lib/rollbar/lazy_store.rb +5 -5
  44. data/lib/rollbar/logger.rb +1 -0
  45. data/lib/rollbar/logger_proxy.rb +15 -2
  46. data/lib/rollbar/middleware/js.rb +110 -10
  47. data/lib/rollbar/middleware/js/json_value.rb +26 -0
  48. data/lib/rollbar/middleware/rack.rb +4 -1
  49. data/lib/rollbar/middleware/rails/rollbar.rb +10 -1
  50. data/lib/rollbar/notifier.rb +118 -49
  51. data/lib/rollbar/notifier/trace_with_bindings.rb +65 -0
  52. data/lib/rollbar/plugin.rb +54 -6
  53. data/lib/rollbar/plugins.rb +7 -1
  54. data/lib/rollbar/plugins/active_job.rb +5 -1
  55. data/lib/rollbar/plugins/basic_socket.rb +21 -6
  56. data/lib/rollbar/plugins/delayed_job/job_data.rb +3 -3
  57. data/lib/rollbar/plugins/delayed_job/plugin.rb +3 -3
  58. data/lib/rollbar/plugins/goalie.rb +11 -3
  59. data/lib/rollbar/plugins/rails/controller_methods.rb +17 -4
  60. data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -3
  61. data/lib/rollbar/plugins/rake.rb +2 -2
  62. data/lib/rollbar/plugins/sidekiq/plugin.rb +10 -6
  63. data/lib/rollbar/rake_tasks.rb +3 -86
  64. data/lib/rollbar/request_data_extractor.rb +35 -21
  65. data/lib/rollbar/rollbar_test.rb +147 -0
  66. data/lib/rollbar/scrubbers.rb +7 -3
  67. data/lib/rollbar/scrubbers/params.rb +38 -20
  68. data/lib/rollbar/scrubbers/url.rb +27 -13
  69. data/lib/rollbar/truncation.rb +9 -2
  70. data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
  71. data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
  72. data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
  73. data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
  74. data/lib/rollbar/truncation/strings_strategy.rb +3 -4
  75. data/lib/rollbar/util.rb +75 -45
  76. data/lib/rollbar/util/hash.rb +30 -6
  77. data/lib/rollbar/util/ip_anonymizer.rb +8 -7
  78. data/lib/rollbar/util/ip_obfuscator.rb +1 -1
  79. data/lib/rollbar/version.rb +1 -1
  80. data/lib/tasks/benchmark.rake +103 -0
  81. data/rollbar.gemspec +14 -8
  82. metadata +25 -277
  83. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -49
  84. data/lib/rollbar/json/default.rb +0 -11
  85. data/lib/rollbar/json/oj.rb +0 -16
  86. data/lib/rollbar/tasks/rollbar.cap +0 -47
  87. data/spec/cacert.pem +0 -3988
  88. data/spec/controllers/home_controller_spec.rb +0 -480
  89. data/spec/delay/sidekiq_spec.rb +0 -61
  90. data/spec/delay/sucker_punch_spec.rb +0 -25
  91. data/spec/delayed/backend/test.rb +0 -140
  92. data/spec/delayed/serialization/test.rb +0 -0
  93. data/spec/dummyapp/.gitignore +0 -73
  94. data/spec/dummyapp/Rakefile +0 -7
  95. data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
  96. data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
  97. data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
  98. data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
  99. data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
  100. data/spec/dummyapp/app/helpers/.gitkeep +0 -0
  101. data/spec/dummyapp/app/mailers/.gitkeep +0 -0
  102. data/spec/dummyapp/app/models/.gitkeep +0 -0
  103. data/spec/dummyapp/app/models/book.rb +0 -5
  104. data/spec/dummyapp/app/models/post.rb +0 -9
  105. data/spec/dummyapp/app/models/user.rb +0 -9
  106. data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
  107. data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
  108. data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
  109. data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
  110. data/spec/dummyapp/app/views/home/index.html.erb +0 -4
  111. data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
  112. data/spec/dummyapp/app/views/js/test.html.erb +0 -1
  113. data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
  114. data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
  115. data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
  116. data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
  117. data/spec/dummyapp/app/views/users/index.html.erb +0 -8
  118. data/spec/dummyapp/app/views/users/show.html.erb +0 -3
  119. data/spec/dummyapp/config.ru +0 -4
  120. data/spec/dummyapp/config/application.rb +0 -59
  121. data/spec/dummyapp/config/boot.rb +0 -10
  122. data/spec/dummyapp/config/database.yml +0 -25
  123. data/spec/dummyapp/config/environment.rb +0 -5
  124. data/spec/dummyapp/config/environments/development.rb +0 -37
  125. data/spec/dummyapp/config/environments/production.rb +0 -67
  126. data/spec/dummyapp/config/environments/test.rb +0 -37
  127. data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
  128. data/spec/dummyapp/config/initializers/inflections.rb +0 -15
  129. data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
  130. data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
  131. data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
  132. data/spec/dummyapp/config/initializers/session_store.rb +0 -8
  133. data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
  134. data/spec/dummyapp/config/locales/devise.en.yml +0 -58
  135. data/spec/dummyapp/config/locales/en.yml +0 -5
  136. data/spec/dummyapp/config/routes.rb +0 -17
  137. data/spec/dummyapp/config/secrets.yml +0 -2
  138. data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
  139. data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
  140. data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
  141. data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
  142. data/spec/dummyapp/db/schema.rb +0 -41
  143. data/spec/dummyapp/db/seeds.rb +0 -12
  144. data/spec/dummyapp/lib/assets/.gitkeep +0 -0
  145. data/spec/dummyapp/public/404.html +0 -26
  146. data/spec/dummyapp/public/422.html +0 -26
  147. data/spec/dummyapp/public/500.html +0 -25
  148. data/spec/dummyapp/public/favicon.ico +0 -0
  149. data/spec/dummyapp/script/rails +0 -6
  150. data/spec/fixtures/file1 +0 -1
  151. data/spec/fixtures/file2 +0 -1
  152. data/spec/fixtures/payloads/message.json +0 -25
  153. data/spec/fixtures/payloads/sample.trace.json +0 -275
  154. data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
  155. data/spec/fixtures/plugins/dummy1.rb +0 -5
  156. data/spec/fixtures/plugins/dummy2.rb +0 -5
  157. data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
  158. data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
  159. data/spec/requests/home_spec.rb +0 -49
  160. data/spec/rollbar/configuration_spec.rb +0 -46
  161. data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
  162. data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
  163. data/spec/rollbar/delay/resque_spec.rb +0 -37
  164. data/spec/rollbar/delay/thread_spec.rb +0 -27
  165. data/spec/rollbar/encoding/encoder_spec.rb +0 -63
  166. data/spec/rollbar/item/backtrace_spec.rb +0 -26
  167. data/spec/rollbar/item/frame_spec.rb +0 -267
  168. data/spec/rollbar/item_spec.rb +0 -736
  169. data/spec/rollbar/json/oj_spec.rb +0 -18
  170. data/spec/rollbar/json_spec.rb +0 -110
  171. data/spec/rollbar/lazy_store_spec.rb +0 -99
  172. data/spec/rollbar/logger_proxy_spec.rb +0 -50
  173. data/spec/rollbar/logger_spec.rb +0 -124
  174. data/spec/rollbar/middleware/js_spec.rb +0 -421
  175. data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
  176. data/spec/rollbar/notifier_spec.rb +0 -56
  177. data/spec/rollbar/plugin_spec.rb +0 -209
  178. data/spec/rollbar/plugins/active_job_spec.rb +0 -38
  179. data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
  180. data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
  181. data/spec/rollbar/plugins/rack_spec.rb +0 -152
  182. data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
  183. data/spec/rollbar/plugins/rake_spec.rb +0 -34
  184. data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
  185. data/spec/rollbar/plugins/sidekiq_spec.rb +0 -171
  186. data/spec/rollbar/plugins/validations_spec.rb +0 -56
  187. data/spec/rollbar/plugins_spec.rb +0 -68
  188. data/spec/rollbar/request_data_extractor_spec.rb +0 -270
  189. data/spec/rollbar/scrubbers/params_spec.rb +0 -314
  190. data/spec/rollbar/scrubbers/url_spec.rb +0 -136
  191. data/spec/rollbar/scrubbers_spec.rb +0 -31
  192. data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
  193. data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
  194. data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
  195. data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
  196. data/spec/rollbar/truncation_spec.rb +0 -27
  197. data/spec/rollbar/util/hash_spec.rb +0 -22
  198. data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
  199. data/spec/rollbar/util_spec.rb +0 -80
  200. data/spec/rollbar_bc_spec.rb +0 -380
  201. data/spec/rollbar_spec.rb +0 -1667
  202. data/spec/spec_helper.rb +0 -84
  203. data/spec/support/cause_exception.rb +0 -1
  204. data/spec/support/encoding_helpers.rb +0 -8
  205. data/spec/support/encodings/iso_8859_9 +0 -1
  206. data/spec/support/fixture_helpers.rb +0 -10
  207. data/spec/support/get_ip_raising.rb +0 -7
  208. data/spec/support/helpers.rb +0 -5
  209. data/spec/support/matchers.rb +0 -23
  210. data/spec/support/notifier_helpers.rb +0 -57
  211. data/spec/support/rollbar_api.rb +0 -57
  212. data/spec/support/shared_contexts.rb +0 -12
@@ -1,5 +0,0 @@
1
- require 'rollbar/plugins'
2
-
3
- Rollbar.plugins.define(:dummy1) do
4
- dependency { true }
5
- end
@@ -1,5 +0,0 @@
1
- require 'rollbar/plugins'
2
-
3
- Rollbar.plugins.define(:dummy2) do
4
- dependency { true }
5
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- begin
4
- require 'genspec'
5
- rescue LoadError
6
- end
7
-
8
- require 'generators/rollbar/rollbar_generator'
9
-
10
- describe :rollbar do
11
- context "with no arguments" do
12
- it "outputs a help message" do
13
- subject.should output(/You'll need to add an environment variable ROLLBAR_ACCESS_TOKEN with your access token/)
14
- end
15
-
16
- it "generates a Rollbar initializer with ENV" do
17
- subject.should generate("config/initializers/rollbar.rb") { |content|
18
- content.should =~ /config.access_token = ENV\['ROLLBAR_ACCESS_TOKEN'\]/
19
- }
20
- end
21
- end
22
-
23
- with_args 'aaaabbbbccccddddeeeeffff00001111' do
24
- it "generates a Rollbar initializer with access token" do
25
- subject.should generate("config/initializers/rollbar.rb") do |content|
26
- content.should =~ /aaaabbbbccccddddeeeeffff00001111/
27
- content.should =~ /config.access_token = 'aaaabbbbccccddddeeeeffff00001111'/
28
- end
29
- end
30
- end
31
- end if Rails::VERSION::STRING.start_with?('3.0')
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- begin
4
- require 'generator_spec'
5
- rescue LoadError
6
- end
7
-
8
- require 'generators/rollbar/rollbar_generator'
9
-
10
- describe Rollbar::Generators::RollbarGenerator, :type => :generator do
11
- destination File.expand_path('../../../tmp', __FILE__)
12
-
13
- before { prepare_destination }
14
-
15
- context 'with no arguments' do
16
- before do
17
- run_generator
18
- end
19
-
20
- it 'outputs a help message and generates Rollbar initializer with ENV' do
21
- expect(destination_root).to have_structure {
22
- directory 'config' do
23
- directory 'initializers' do
24
- file 'rollbar.rb' do
25
- contains "config.access_token = ENV\['ROLLBAR_ACCESS_TOKEN'\]"
26
- end
27
- end
28
- end
29
- }
30
- end
31
- end
32
-
33
- context 'with arguments' do
34
- before do
35
- run_generator(%w(aaaabbbbccccddddeeeeffff00001111))
36
- end
37
-
38
- it 'generates a Rollbar initializer with access token' do
39
- expect(destination_root).to have_structure {
40
- directory 'config' do
41
- directory 'initializers' do
42
- file 'rollbar.rb' do
43
- contains 'aaaabbbbccccddddeeeeffff00001111'
44
- contains "config.access_token = 'aaaabbbbccccddddeeeeffff00001111'"
45
- end
46
- end
47
- end
48
- }
49
- end
50
- end
51
- end unless Rails::VERSION::STRING.start_with?('3.0')
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HomeController do
4
- let(:logger_mock) { double("Rails.logger").as_null_object }
5
-
6
- before(:each) do
7
- reset_configuration
8
- reconfigure_notifier
9
- end
10
-
11
- context "with broken request" do
12
- it "should report uncaught exceptions" do
13
- # only seems to be relevant in 3.1 and 3.2
14
- if ::Rails::VERSION::STRING.starts_with? "3.1" or ::Rails::VERSION::STRING.starts_with? "3.2"
15
- expect { get '/current_user', nil, :cookie => '8%B' }.to raise_exception
16
-
17
- Rollbar.last_report.should_not be_nil
18
-
19
- exception_info = Rollbar.last_report[:body][:trace][:exception]
20
- exception_info[:class].should == 'ArgumentError'
21
- exception_info[:message].should == 'invalid %-encoding (8%B)'
22
- end
23
- end
24
- end
25
-
26
- context "with error hiding deep inside" do
27
- let!(:cookie_method_name){ :[] }
28
- let!(:original_cookie_method){ ActionDispatch::Cookies::CookieJar.instance_method(cookie_method_name) }
29
- let!(:broken_cookie_method){ Proc.new{ |name| "1" - 1 } }
30
-
31
- before(:each) do
32
- ActionDispatch::Cookies::CookieJar.send(:define_method, cookie_method_name, broken_cookie_method)
33
- end
34
-
35
- after do
36
- ActionDispatch::Cookies::CookieJar.send(:define_method, cookie_method_name, original_cookie_method)
37
- end
38
-
39
- it "should report uncaught exceptions" do
40
- expect { get '/current_user' }.to raise_exception(NoMethodError)
41
-
42
- body = Rollbar.last_report[:body]
43
- trace = body[:trace] && body[:trace] || body[:trace_chain][0]
44
-
45
- trace[:exception][:class].should == 'NoMethodError'
46
- trace[:exception][:message].should =~ /^undefined method `-'/
47
- end
48
- end
49
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'rollbar/configuration'
3
-
4
- describe Rollbar::Configuration do
5
-
6
- describe '#use_thread' do
7
- it 'enables async and sets a Thread as handler' do
8
- subject.use_thread
9
-
10
- expect(subject.use_async).to be_eql(true)
11
- expect(subject.async_handler).to be_eql(Rollbar::Delay::Thread)
12
- end
13
- end
14
-
15
- describe '#use_resque' do
16
- it 'enables async and sets Resque as the handler' do
17
- require 'resque'
18
- subject.use_resque(:queue => 'errors')
19
-
20
- expect(subject.use_async).to be_eql(true)
21
- expect(subject.async_handler).to be_eql(Rollbar::Delay::Resque)
22
- end
23
- end
24
-
25
- describe '#merge' do
26
- it 'returns a new object with overrided values' do
27
- subject.environment = 'foo'
28
-
29
- new_config = subject.merge(:environment => 'bar')
30
-
31
- expect(new_config).not_to be(subject)
32
- expect(new_config.environment).to be_eql('bar')
33
- end
34
- end
35
-
36
- describe '#merge!' do
37
- it 'returns the same object with overrided values' do
38
- subject.environment = 'foo'
39
-
40
- new_config = subject.merge!(:environment => 'bar')
41
-
42
- expect(new_config).to be(subject)
43
- expect(new_config.environment).to be_eql('bar')
44
- end
45
- end
46
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'delayed_job'
4
- require 'delayed/worker'
5
- require 'rollbar/delay/delayed_job'
6
- require 'delayed/backend/test'
7
-
8
- describe Rollbar::Delay::DelayedJob do
9
- before do
10
- Delayed::Backend::Test.prepare_worker
11
- Delayed::Worker.backend = :test
12
- end
13
-
14
- describe '.call' do
15
- let(:payload) { {} }
16
- it 'calls Rollbar' do
17
- expect(Rollbar).to receive(:process_from_async_handler).with(payload)
18
-
19
- Rollbar::Delay::DelayedJob.call(payload)
20
- end
21
- end
22
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # require girl_friday in the test instead in the implementation
4
- # just to let the user decide to load it or not
5
- require 'girl_friday'
6
- require 'rollbar/delay/girl_friday'
7
-
8
- describe Rollbar::Delay::GirlFriday do
9
- before do
10
- queue_class = ::GirlFriday::WorkQueue.immediate!
11
- allow(::Rollbar::Delay::GirlFriday).to receive(:queue_class).and_return(queue_class)
12
- end
13
-
14
- describe '.call' do
15
- let(:payload) do
16
- { :key => 'value' }
17
- end
18
-
19
- it 'push the payload into the queue' do
20
- expect(Rollbar).to receive(:process_from_async_handler).with(payload)
21
-
22
- described_class.call(payload)
23
- end
24
-
25
- context 'with exceptions processing payload' do
26
- let(:exception) { Exception.new }
27
-
28
- before do
29
- expect(Rollbar).to receive(:process_from_async_handler).with(payload).and_raise(exception)
30
- end
31
-
32
- it 'raises an exception cause we are using immediate queue' do
33
- # This will not happen with a norma work queue cause this:
34
- # https://github.com/mperham/girl_friday/blob/master/lib/girl_friday/work_queue.rb#L90-L106
35
- expect do
36
- described_class.call(payload)
37
- end.to raise_error(exception)
38
- end
39
- end
40
- end
41
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
- require 'rollbar/delay/resque'
3
-
4
- describe Rollbar::Delay::Resque do
5
- describe '.call' do
6
- let(:payload) do
7
- { :key => 'value' }
8
- end
9
-
10
- let(:loaded_hash) do
11
- Rollbar::JSON.load(Rollbar::JSON.dump(payload))
12
- end
13
-
14
- before do
15
- allow(Resque).to receive(:inline?).and_return(true)
16
- end
17
-
18
- it 'process the payload' do
19
- expect(Rollbar).to receive(:process_from_async_handler).with(loaded_hash)
20
- described_class.call(payload)
21
- end
22
-
23
- context 'with exceptions processing payload' do
24
- let(:exception) { Exception.new }
25
-
26
- before do
27
- expect(Rollbar).to receive(:process_from_async_handler).with(loaded_hash).and_raise(exception)
28
- end
29
-
30
- it 'raises an exception' do
31
- expect do
32
- described_class.call(payload)
33
- end.to raise_error(exception)
34
- end
35
- end
36
- end
37
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rollbar::Delay::Thread do
4
- describe '.call' do
5
- let(:payload) { { :key => 'value' } }
6
-
7
- it 'process the payload in a new thread' do
8
- expect(Rollbar).to receive(:process_from_async_handler).with(payload)
9
-
10
- described_class.call(payload).join
11
- end
12
-
13
- context 'with exceptions processing payload' do
14
- let(:exception) { StandardError.new }
15
-
16
- before do
17
- expect(Rollbar).to receive(:process_from_async_handler).with(payload).and_raise(exception)
18
- end
19
-
20
- it 'doesnt raise any exception' do
21
- expect do
22
- described_class.call(payload).join
23
- end.not_to raise_error
24
- end
25
- end
26
- end
27
- end
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- unless RUBY_VERSION.start_with?('1.8')
5
- require 'rollbar/encoding/encoder'
6
-
7
- describe Rollbar::Encoding::Encoder do
8
- subject { described_class.new(object) }
9
-
10
- shared_examples 'encoding' do
11
- it 'encodes ir properly' do
12
- value = subject.encode
13
-
14
- expect(value).to be_eql(expected)
15
- end
16
- end
17
-
18
- describe '#encode' do
19
- context 'with ascii chars at end of string' do
20
- it_behaves_like 'encoding' do
21
- let(:object) { force_to_ascii("bad value 1\255") }
22
- let(:expected) { 'bad value 1' }
23
- end
24
- end
25
-
26
- context 'with ascii chars at middle of string' do
27
- it_behaves_like 'encoding' do
28
- let(:object) { force_to_ascii("bad\255 value 2") }
29
- let(:expected) { 'bad value 2' }
30
- end
31
- end
32
-
33
- context 'with ascii chars at end of string' do
34
- it_behaves_like 'encoding' do
35
- let(:object) { force_to_ascii("bad value 3\255") }
36
- let(:expected) { 'bad value 3' }
37
- end
38
- end
39
-
40
- context '0xa0 char in exception object' do
41
- it_behaves_like 'encoding' do
42
- let(:object) { "foo \xa0".force_encoding(::Encoding::ISO_8859_1) }
43
- let(:expected) { "foo " }
44
- end
45
- end
46
-
47
- context 'with bad symbol' do
48
- it_behaves_like 'encoding' do
49
- let(:bad_string) { force_to_ascii("inner \x92bad key") }
50
- let(:object) { bad_string.to_sym }
51
- let(:expected) { :"inner bad key" }
52
- end
53
- end
54
-
55
- context 'with russian chars in string' do
56
- it_behaves_like 'encoding' do
57
- let(:object) { 'Изменение' }
58
- let(:expected) { 'Изменение' }
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
- require 'rollbar/item/backtrace'
4
-
5
- describe Rollbar::Item::Backtrace do
6
- describe '#get_file_lines' do
7
- subject { described_class.new(exception) }
8
-
9
- let(:exception) { Exception.new }
10
- let(:file) { Tempfile.new('foo') }
11
-
12
- before do
13
- File.open(file.path, 'w') do |f|
14
- f << "foo\nbar"
15
- end
16
- end
17
-
18
- it 'returns the lines of the file' do
19
- lines = subject.get_file_lines(file.path)
20
-
21
- expect(lines.size).to be_eql(2)
22
- expect(lines[0]).to be_eql('foo')
23
- expect(lines[1]).to be_eql('bar')
24
- end
25
- end
26
- end
@@ -1,267 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
- require 'rollbar/item/backtrace'
4
- require 'rollbar/item/frame'
5
-
6
- describe Rollbar::Item::Frame do
7
- subject { described_class.new(backtrace, frame, options) }
8
-
9
- let(:backtrace) { double('backtrace') }
10
- let(:options) { {} }
11
-
12
- describe '#to_h' do
13
- context 'with a frame that is not a valid frame' do
14
- let(:frame) { 'this frame is not valid' }
15
-
16
- it 'return an unknown frame value' do
17
- expected_result = {
18
- :filename => '<unknown>',
19
- :lineno => 0,
20
- :method => frame
21
- }
22
-
23
- result = subject.to_h
24
- expect(result).to be_eql(expected_result)
25
- end
26
- end
27
-
28
- context 'with valid frame' do
29
- let(:file) do
30
- <<-END
31
- foo1
32
- foo2
33
- foo3
34
- foo4
35
- foo5
36
- foo6
37
- foo7
38
- foo8
39
- foo9
40
- foo10
41
- foo11
42
- foo12
43
- foo13
44
- END
45
- end
46
- let(:filepath) do
47
- '/var/www/rollbar/playground/rails4.2/vendor/bundle/gems/actionpack-4.2.0/lib/action_controller/metal/implicit_render.rb'
48
- end
49
- let(:frame) do
50
- "#{filepath}:7:in `send_action'"
51
- end
52
- let(:options) do
53
- { :configuration => configuration }
54
- end
55
-
56
- before do
57
- allow(backtrace).to receive(:get_file_lines).with(filepath).and_return(file.split("\n"))
58
- end
59
-
60
- context 'with send_extra_frame_data = :none' do
61
- let(:configuration) do
62
- double('configuration',
63
- :send_extra_frame_data => :none,
64
- :root => '/var/www')
65
- end
66
-
67
- it 'just return the filename, lineno and method' do
68
- expected_result = {
69
- :filename => filepath,
70
- :lineno => 7,
71
- :method => 'send_action'
72
- }
73
-
74
- expect(subject.to_h).to be_eql(expected_result)
75
- end
76
- end
77
-
78
- context 'with send_extra_frame_data = :all' do
79
- let(:configuration) do
80
- double('configuration',
81
- :send_extra_frame_data => :all,
82
- :root => '/var/www')
83
- end
84
-
85
- it 'returns also code and context' do
86
- expected_result = {
87
- :filename => filepath,
88
- :lineno => 7,
89
- :method => 'send_action',
90
- :code => 'foo7',
91
- :context => {
92
- :pre => %w(foo3 foo4 foo5 foo6),
93
- :post => %w(foo8 foo9 foo10 foo11)
94
- }
95
- }
96
-
97
- expect(subject.to_h).to be_eql(expected_result)
98
- end
99
-
100
- context 'if there is not lines in the file' do
101
- let(:file) do
102
- ''
103
- end
104
- it 'just returns the basic data' do
105
- expected_result = {
106
- :filename => filepath,
107
- :lineno => 7,
108
- :method => 'send_action'
109
- }
110
-
111
- expect(subject.to_h).to be_eql(expected_result)
112
- end
113
- end
114
-
115
- context 'if the file couldnt be read' do
116
- before do
117
- allow(backtrace).to receive(:get_file_lines).with(filepath).and_return(nil)
118
- end
119
-
120
- it 'just returns the basic data' do
121
- expected_result = {
122
- :filename => filepath,
123
- :lineno => 7,
124
- :method => 'send_action'
125
- }
126
-
127
- expect(subject.to_h).to be_eql(expected_result)
128
- end
129
- end
130
- end
131
-
132
- context 'with send_extra_frame_data = :app' do
133
- context 'with frame outside the root' do
134
- let(:configuration) do
135
- double('configuration',
136
- :send_extra_frame_data => :app,
137
- :root => '/outside/project',
138
- :project_gem_paths => [])
139
- end
140
-
141
- it 'just returns the basic frame data' do
142
- expected_result = {
143
- :filename => filepath,
144
- :lineno => 7,
145
- :method => 'send_action'
146
- }
147
-
148
- expect(subject.to_h).to be_eql(expected_result)
149
- end
150
- end
151
-
152
- context 'with frame inside project_gem_paths' do
153
- let(:configuration) do
154
- double('configuration',
155
- :send_extra_frame_data => :app,
156
- :root => '/var/outside/',
157
- :project_gem_paths => ['/var/www/'])
158
- end
159
-
160
- it 'returns also context and code data' do
161
- expected_result = {
162
- :filename => filepath,
163
- :lineno => 7,
164
- :method => 'send_action',
165
- :code => 'foo7',
166
- :context => {
167
- :pre => %w(foo3 foo4 foo5 foo6),
168
- :post => %w(foo8 foo9 foo10 foo11)
169
- }
170
- }
171
-
172
- expect(subject.to_h).to be_eql(expected_result)
173
- end
174
- end
175
-
176
- context 'and frame inside app root' do
177
- let(:configuration) do
178
- double('configuration',
179
- :send_extra_frame_data => :app,
180
- :root => '/var/www',
181
- :project_gem_paths => [])
182
- end
183
-
184
- it 'returns also the context and code data' do
185
- expected_result = {
186
- :filename => filepath,
187
- :lineno => 7,
188
- :method => 'send_action',
189
- :code => 'foo7',
190
- :context => {
191
- :pre => %w(foo3 foo4 foo5 foo6),
192
- :post => %w(foo8 foo9 foo10 foo11)
193
- }
194
- }
195
-
196
- expect(subject.to_h).to be_eql(expected_result)
197
- end
198
-
199
- context 'but inside Gem.path' do
200
- let(:configuration) do
201
- double('configuration',
202
- :send_extra_frame_data => :app,
203
- :root => '/var/www/',
204
- :project_gem_paths => [])
205
- end
206
-
207
- before do
208
- allow(Gem).to receive(:path).and_return(['/var/www/rollbar'])
209
- end
210
-
211
- it 'just returns also the basic data' do
212
- expected_result = {
213
- :filename => filepath,
214
- :lineno => 7,
215
- :method => 'send_action'
216
- }
217
-
218
- expect(subject.to_h).to be_eql(expected_result)
219
- end
220
- end
221
-
222
- context 'having less pre lines than maximum' do
223
- let(:frame) do
224
- "#{filepath}:3:in `send_action'"
225
- end
226
-
227
- it 'returns up to 2 pre lines' do
228
- expected_result = {
229
- :filename => filepath,
230
- :lineno => 3,
231
- :method => 'send_action',
232
- :code => 'foo3',
233
- :context => {
234
- :pre => %w(foo1 foo2),
235
- :post => %w(foo4 foo5 foo6 foo7)
236
- }
237
- }
238
-
239
- expect(subject.to_h).to be_eql(expected_result)
240
- end
241
- end
242
-
243
- context 'having less post lines than maximum' do
244
- let(:frame) do
245
- "#{filepath}:11:in `send_action'"
246
- end
247
-
248
- it 'returns up to 2 post lines' do
249
- expected_result = {
250
- :filename => filepath,
251
- :lineno => 11,
252
- :method => 'send_action',
253
- :code => 'foo11',
254
- :context => {
255
- :pre => %w(foo7 foo8 foo9 foo10),
256
- :post => %w(foo12 foo13)
257
- }
258
- }
259
-
260
- expect(subject.to_h).to be_eql(expected_result)
261
- end
262
- end
263
- end
264
- end
265
- end
266
- end
267
- end