appsignal 1.4.0.alpha.2 → 1.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -1
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +38 -1
  5. data/Rakefile +29 -12
  6. data/benchmark.rake +3 -7
  7. data/ext/agent.yml +11 -11
  8. data/ext/appsignal_extension.c +364 -72
  9. data/ext/extconf.rb +2 -4
  10. data/gemfiles/resque.gemfile +1 -0
  11. data/lib/appsignal.rb +40 -30
  12. data/lib/appsignal/auth_check.rb +1 -1
  13. data/lib/appsignal/cli/diagnose.rb +4 -3
  14. data/lib/appsignal/cli/install.rb +16 -15
  15. data/lib/appsignal/config.rb +31 -31
  16. data/lib/appsignal/event_formatter.rb +1 -1
  17. data/lib/appsignal/extension.rb +6 -0
  18. data/lib/appsignal/garbage_collection_profiler.rb +47 -0
  19. data/lib/appsignal/hooks.rb +1 -0
  20. data/lib/appsignal/hooks/active_support_notifications.rb +43 -0
  21. data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
  22. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -2
  23. data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -1
  24. data/lib/appsignal/integrations/object.rb +4 -4
  25. data/lib/appsignal/integrations/padrino.rb +1 -1
  26. data/lib/appsignal/integrations/sinatra.rb +1 -1
  27. data/lib/appsignal/integrations/webmachine.rb +2 -2
  28. data/lib/appsignal/js_exception_transaction.rb +7 -10
  29. data/lib/appsignal/marker.rb +3 -2
  30. data/lib/appsignal/rack/generic_instrumentation.rb +1 -1
  31. data/lib/appsignal/rack/sinatra_instrumentation.rb +13 -6
  32. data/lib/appsignal/rack/streaming_listener.rb +5 -3
  33. data/lib/appsignal/system.rb +36 -0
  34. data/lib/appsignal/transaction.rb +20 -20
  35. data/lib/appsignal/transmitter.rb +11 -7
  36. data/lib/appsignal/utils.rb +76 -2
  37. data/lib/appsignal/version.rb +1 -1
  38. data/spec/lib/appsignal/auth_check_spec.rb +0 -2
  39. data/spec/lib/appsignal/capistrano2_spec.rb +99 -79
  40. data/spec/lib/appsignal/capistrano3_spec.rb +57 -78
  41. data/spec/lib/appsignal/cli/diagnose_spec.rb +17 -15
  42. data/spec/lib/appsignal/cli/install_spec.rb +38 -20
  43. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +2 -5
  44. data/spec/lib/appsignal/cli_spec.rb +2 -5
  45. data/spec/lib/appsignal/config_spec.rb +385 -158
  46. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +1 -3
  47. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -2
  48. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -2
  49. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -2
  50. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -2
  51. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -2
  52. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +0 -2
  53. data/spec/lib/appsignal/event_formatter_spec.rb +0 -2
  54. data/spec/lib/appsignal/extension_spec.rb +7 -8
  55. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +71 -0
  56. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +42 -0
  57. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -2
  58. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -2
  59. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -2
  60. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -2
  61. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -2
  62. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -2
  63. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -2
  64. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
  65. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -2
  66. data/spec/lib/appsignal/hooks/sequel_spec.rb +19 -21
  67. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +1 -4
  68. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -3
  69. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -2
  70. data/spec/lib/appsignal/hooks/webmachine_spec.rb +4 -11
  71. data/spec/lib/appsignal/hooks_spec.rb +0 -2
  72. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -1
  73. data/spec/lib/appsignal/integrations/grape_spec.rb +1 -3
  74. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +1 -2
  75. data/spec/lib/appsignal/integrations/object_spec.rb +32 -3
  76. data/spec/lib/appsignal/integrations/padrino_spec.rb +4 -11
  77. data/spec/lib/appsignal/integrations/railtie_spec.rb +1 -3
  78. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +1 -3
  79. data/spec/lib/appsignal/integrations/resque_spec.rb +2 -4
  80. data/spec/lib/appsignal/integrations/sinatra_spec.rb +33 -8
  81. data/spec/lib/appsignal/integrations/webmachine_spec.rb +6 -15
  82. data/spec/lib/appsignal/js_exception_transaction_spec.rb +3 -5
  83. data/spec/lib/appsignal/marker_spec.rb +35 -48
  84. data/spec/lib/appsignal/minutely_spec.rb +0 -2
  85. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -2
  86. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -2
  87. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -5
  88. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +47 -11
  89. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +6 -7
  90. data/spec/lib/appsignal/system/container_spec.rb +67 -0
  91. data/spec/lib/appsignal/system_spec.rb +49 -0
  92. data/spec/lib/appsignal/transaction_spec.rb +30 -13
  93. data/spec/lib/appsignal/transmitter_spec.rb +53 -20
  94. data/spec/lib/appsignal/utils/gzip_spec.rb +10 -0
  95. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +0 -2
  96. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -2
  97. data/spec/lib/appsignal/utils_spec.rb +59 -3
  98. data/spec/lib/appsignal_spec.rb +132 -58
  99. data/spec/spec_helper.rb +24 -116
  100. data/spec/support/fixtures/containers/cgroups/docker +14 -0
  101. data/spec/support/fixtures/containers/cgroups/docker_systemd +8 -0
  102. data/spec/support/fixtures/containers/cgroups/lxc +10 -0
  103. data/spec/support/fixtures/containers/cgroups/no_permission +0 -0
  104. data/spec/support/fixtures/containers/cgroups/none +1 -0
  105. data/spec/support/helpers/api_request_helper.rb +22 -0
  106. data/spec/support/helpers/dependency_helper.rb +61 -0
  107. data/spec/support/helpers/directory_helper.rb +27 -0
  108. data/spec/support/helpers/std_streams_helper.rb +35 -0
  109. data/spec/support/helpers/system_helpers.rb +24 -0
  110. data/spec/support/helpers/transaction_helpers.rb +7 -64
  111. data/spec/support/helpers/very_specific_error.rb +8 -0
  112. data/spec/support/mocks/fake_gc_profiler.rb +19 -0
  113. data/spec/support/project_fixture/config/appsignal.yml +10 -1
  114. metadata +60 -35
  115. data/circle.yml +0 -12
  116. data/lib/appsignal/subscriber.rb +0 -55
  117. data/lib/appsignal/update_active_support.rb +0 -20
  118. data/lib/vendor/active_support/notifications.rb +0 -212
  119. data/lib/vendor/active_support/notifications/fanout.rb +0 -157
  120. data/lib/vendor/active_support/notifications/instrumenter.rb +0 -73
  121. data/lib/vendor/active_support/per_thread_registry.rb +0 -53
  122. data/spec/lib/appsignal/subscriber_spec.rb +0 -160
  123. data/spec/lib/appsignal/update_active_support_spec.rb +0 -17
  124. data/spec/support/helpers/notification_helpers.rb +0 -14
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require './spec/support/mocks/mock_extension'
3
2
 
4
3
  describe Appsignal do
@@ -9,7 +8,7 @@ describe Appsignal do
9
8
  Appsignal.extensions.clear
10
9
  end
11
10
 
12
- let(:transaction) { regular_transaction }
11
+ let(:transaction) { http_request_transaction }
13
12
 
14
13
  describe ".config=" do
15
14
  it "should set the config" do
@@ -67,11 +66,6 @@ describe Appsignal do
67
66
  Appsignal.start
68
67
  end
69
68
 
70
- it "should create a subscriber" do
71
- Appsignal.start
72
- Appsignal.subscriber.should be_a(Appsignal::Subscriber)
73
- end
74
-
75
69
  context "when not active for this environment" do
76
70
  before { Appsignal.config = project_fixture_config('staging') }
77
71
 
@@ -92,18 +86,23 @@ describe Appsignal do
92
86
 
93
87
  context "when allocation tracking and gc instrumentation have been enabled" do
94
88
  before do
89
+ allow(GC::Profiler).to receive(:enable)
95
90
  Appsignal.config.config_hash[:enable_allocation_tracking] = true
96
91
  Appsignal.config.config_hash[:enable_gc_instrumentation] = true
97
92
  end
98
93
 
99
- it "should install event hooks" do
100
- Appsignal::Extension.should_receive(:install_allocation_event_hook)
101
- Appsignal::Extension.should_receive(:install_gc_event_hooks)
94
+ it "should enable Ruby's GC::Profiler" do
95
+ expect(GC::Profiler).to receive(:enable)
96
+ Appsignal.start
97
+ end
98
+
99
+ it "should install the allocation event hook" do
100
+ expect(Appsignal::Extension).to receive(:install_allocation_event_hook)
102
101
  Appsignal.start
103
102
  end
104
103
 
105
104
  it "should add the gc probe to minutely" do
106
- Appsignal::Minutely.should_receive(:add_gc_probe)
105
+ expect(Appsignal::Minutely).to receive(:add_gc_probe)
107
106
  Appsignal.start
108
107
  end
109
108
  end
@@ -114,14 +113,18 @@ describe Appsignal do
114
113
  Appsignal.config.config_hash[:enable_gc_instrumentation] = false
115
114
  end
116
115
 
117
- it "should not install event hooks" do
118
- Appsignal::Extension.should_not_receive(:install_allocation_event_hook)
119
- Appsignal::Extension.should_not_receive(:install_gc_event_hooks)
116
+ it "should not enable Ruby's GC::Profiler" do
117
+ expect(GC::Profiler).not_to receive(:enable)
118
+ Appsignal.start
119
+ end
120
+
121
+ it "should not install the allocation event hook" do
122
+ expect(Appsignal::Minutely).not_to receive(:install_allocation_event_hook)
120
123
  Appsignal.start
121
124
  end
122
125
 
123
126
  it "should not add the gc probe to minutely" do
124
- Appsignal::Minutely.should_not_receive(:add_gc_probe)
127
+ expect(Appsignal::Minutely).not_to receive(:add_gc_probe)
125
128
  Appsignal.start
126
129
  end
127
130
  end
@@ -163,7 +166,6 @@ describe Appsignal do
163
166
  context "when not active" do
164
167
  it "should should do nothing" do
165
168
  Appsignal::Extension.should_not_receive(:start)
166
- Appsignal::Subscriber.should_not_receive(:new)
167
169
 
168
170
  Appsignal.forked
169
171
  end
@@ -177,7 +179,6 @@ describe Appsignal do
177
179
  it "should resubscribe and start the extension" do
178
180
  Appsignal.should_receive(:start_logger)
179
181
  Appsignal::Extension.should_receive(:start)
180
- Appsignal::Subscriber.any_instance.should_receive(:resubscribe)
181
182
 
182
183
  Appsignal.forked
183
184
  end
@@ -252,7 +253,7 @@ describe Appsignal do
252
253
  describe ".monitor_transaction" do
253
254
  it "should do nothing but still yield the block" do
254
255
  Appsignal::Transaction.should_not_receive(:create)
255
- ActiveSupport::Notifications.should_not_receive(:instrument)
256
+ Appsignal.should_not_receive(:instrument)
256
257
  object = double
257
258
  object.should_receive(:some_method).and_return(1)
258
259
 
@@ -322,7 +323,7 @@ describe Appsignal do
322
323
  describe ".monitor_transaction" do
323
324
  context "with a successful call" do
324
325
  it "should instrument and complete for a background job" do
325
- ActiveSupport::Notifications.should_receive(:instrument).with(
326
+ Appsignal.should_receive(:instrument).with(
326
327
  'perform_job.something'
327
328
  ).and_yield
328
329
  Appsignal::Transaction.should_receive(:complete_current!)
@@ -341,7 +342,7 @@ describe Appsignal do
341
342
  end
342
343
 
343
344
  it "should instrument and complete for a http request" do
344
- ActiveSupport::Notifications.should_receive(:instrument).with(
345
+ Appsignal.should_receive(:instrument).with(
345
346
  'process_action.something'
346
347
  ).and_yield
347
348
  Appsignal::Transaction.should_receive(:complete_current!)
@@ -361,7 +362,7 @@ describe Appsignal do
361
362
  end
362
363
 
363
364
  context "with an erroring call" do
364
- let(:error) { VerySpecificError.new('the roof') }
365
+ let(:error) { VerySpecificError.new }
365
366
 
366
367
  it "should add the error to the current transaction and complete" do
367
368
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
@@ -392,7 +393,7 @@ describe Appsignal do
392
393
  end
393
394
 
394
395
  context "with an erroring call" do
395
- let(:error) { VerySpecificError.new('the roof') }
396
+ let(:error) { VerySpecificError.new }
396
397
 
397
398
  it "should call monitor_transaction and stop and then raise the error" do
398
399
  Appsignal.should_receive(:monitor_transaction).with(
@@ -551,69 +552,123 @@ describe Appsignal do
551
552
 
552
553
  describe ".start_logger" do
553
554
  let(:out_stream) { StringIO.new }
554
- let(:log_path) { File.join(project_fixture_path, 'log') }
555
+ let(:log_path) { File.join(tmp_dir, 'log') }
555
556
  let(:log_file) { File.join(log_path, 'appsignal.log') }
556
557
 
557
558
  before do
558
- FileUtils.rm_f(log_file)
559
- @original_stdout = $stdout
560
- $stdout = out_stream
561
- Appsignal.logger.error('Log something')
559
+ FileUtils.mkdir_p(log_path)
560
+
561
+ Appsignal.logger.error('Log in memory')
562
562
  Appsignal.config = project_fixture_config(
563
563
  'production',
564
564
  :log_path => log_path
565
565
  )
566
566
  end
567
- after do
568
- $stdout = @original_stdout
567
+ around do |example|
568
+ capture_stdout(out_stream) { example.run }
569
569
  end
570
+ after { FileUtils.rm_rf(log_path) }
570
571
 
571
572
  context "when the log path is writable" do
572
- it "should log to file" do
573
- Appsignal.start_logger
574
- Appsignal.logger.level.should eq Logger::INFO
575
- Appsignal.logger.error('Log to file')
576
- File.exist?(log_file).should be_true
577
- File.open(log_file).read.should include 'Log to file'
578
- File.open(log_file).read.should include 'Log something'
573
+ context "when the log file is writable" do
574
+ let(:log_file_contents) { File.open(log_file).read }
575
+ before do
576
+ Appsignal.start_logger
577
+ Appsignal.logger.error('Log to file')
578
+ end
579
+
580
+ it "logs to file" do
581
+ expect(File.exist?(log_file)).to be_true
582
+ expect(log_file_contents).to include 'Log to file'
583
+ end
584
+
585
+ it "amends in memory log to log file" do
586
+ expect(log_file_contents).to include 'Log in memory'
587
+ end
588
+ end
589
+
590
+ context "when the log file is not writable" do
591
+ before do
592
+ FileUtils.touch log_file
593
+ FileUtils.chmod 0444, log_file
594
+
595
+ Appsignal.start_logger
596
+ Appsignal.logger.error('Log to not writable log file')
597
+ end
598
+
599
+ it "logs to stdout" do
600
+ expect(File.writable?(log_file)).to be_false
601
+ expect(out_stream.string).to include 'Log to not writable log file'
602
+ end
603
+
604
+ it "outputs a warning" do
605
+ output = out_stream.string
606
+ expect(output).to include "appsignal: Unable to start logger with "\
607
+ "log path '#{log_file}'."
608
+ expect(output).to include "appsignal: Permission denied"
609
+ end
579
610
  end
580
611
  end
581
612
 
582
- context "when we're on Heroku" do
613
+ context "when the log path is not writable" do
583
614
  before do
584
- ENV['DYNO'] = 'dyno1'
615
+ FileUtils.chmod 0444, log_path
616
+
617
+ Appsignal.start_logger
618
+ Appsignal.logger.error('Log to not writable log path')
585
619
  end
586
- after { ENV.delete('DYNO') }
587
620
 
588
- it "should log to stdout" do
621
+ it "logs to stdout" do
622
+ expect(File.writable?(log_path)).to be_false
623
+ expect(out_stream.string).to include 'Log to not writable log path'
624
+ end
625
+
626
+ it "amends in memory log to stdout" do
627
+ expect(out_stream.string).to include 'Log in memory'
628
+ end
629
+ end
630
+
631
+ context "when on Heroku" do
632
+ before do
589
633
  Appsignal.start_logger
590
- Appsignal.logger.level.should eq Logger::INFO
591
634
  Appsignal.logger.error('Log to stdout')
635
+ end
636
+ around { |example| recognize_as_heroku { example.run } }
637
+
638
+ it "should log to stdout" do
592
639
  out_stream.string.should include 'appsignal: Log to stdout'
593
- out_stream.string.should include 'Log something'
594
640
  end
595
- end
596
641
 
597
- context "when there is no in memory log" do
598
- it "should not crash" do
599
- Appsignal.in_memory_log = nil
600
- Appsignal.start_logger
642
+ it "amends in memory log to stdout" do
643
+ expect(out_stream.string).to include 'Log in memory'
601
644
  end
602
645
  end
603
646
 
604
- context "when there is no config and debug is on" do
605
- it "should set the log level to info" do
606
- Appsignal.config = nil
607
- Appsignal.start_logger
608
- Appsignal.logger.level.should eq Logger::INFO
647
+ describe "#logger#level" do
648
+ subject { Appsignal.logger.level }
649
+
650
+ context "when there is no config" do
651
+ before do
652
+ Appsignal.config = nil
653
+ Appsignal.start_logger
654
+ end
655
+
656
+ it "sets the log level to info" do
657
+ expect(subject).to eq Logger::INFO
658
+ end
609
659
  end
610
- end
611
660
 
612
- context "when there is a config and debug is on" do
613
- it "should set the log level to debug" do
614
- Appsignal.config.config_hash[:debug] = true
615
- Appsignal.start_logger
616
- Appsignal.logger.level.should eq Logger::DEBUG
661
+ context "when there is a config" do
662
+ context "when log level is configured to debug" do
663
+ before do
664
+ Appsignal.config.config_hash[:debug] = true
665
+ Appsignal.start_logger
666
+ end
667
+
668
+ it "sets the log level to debug" do
669
+ expect(subject).to eq Logger::DEBUG
670
+ end
671
+ end
617
672
  end
618
673
  end
619
674
  end
@@ -744,6 +799,25 @@ describe Appsignal do
744
799
  end
745
800
  end
746
801
 
802
+ describe ".instrument_sql" do
803
+ it "should instrument sql through the transaction" do
804
+ stub = double
805
+ stub.should_receive(:method_call).and_return('return value')
806
+
807
+ transaction.should_receive(:start_event)
808
+ transaction.should_receive(:finish_event).with(
809
+ 'name',
810
+ 'title',
811
+ 'body',
812
+ 1
813
+ )
814
+
815
+ Appsignal.instrument_sql 'name', 'title', 'body' do
816
+ stub.method_call
817
+ end.should eq 'return value'
818
+ end
819
+ end
820
+
747
821
  describe ".without_instrumentation" do
748
822
  let(:transaction) { double }
749
823
  before { Appsignal::Transaction.stub(:current => transaction) }
@@ -1,125 +1,28 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
+ ENV['RACK_ENV'] ||= 'test'
2
3
  ENV['PADRINO_ENV'] ||= 'test'
3
4
 
5
+ APPSIGNAL_SPEC_DIR = File.expand_path(File.dirname(__FILE__))
6
+ $LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, 'support/stubs'))
7
+
8
+ Bundler.require :default
4
9
  require 'rack'
5
10
  require 'rspec'
6
11
  require 'pry'
7
12
  require 'timecop'
8
13
  require 'webmock/rspec'
9
14
 
10
- puts "Runnings specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}"
11
-
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support/stubs'))
13
-
14
- begin
15
- require 'rails'
16
- Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support/rails','*.rb'))].each {|f| require f}
17
- puts 'Rails present, running Rails specific specs'
18
- RAILS_PRESENT = true
19
- rescue LoadError
20
- puts 'Rails not present, skipping Rails specific specs'
21
- RAILS_PRESENT = false
22
- end
23
-
24
- def rails_present?
25
- RAILS_PRESENT
26
- end
27
-
28
- def active_job_present?
29
- require 'active_job'
30
- true
31
- rescue LoadError
32
- false
33
- end
34
-
35
- def active_record_present?
36
- require 'active_record'
37
- true
38
- rescue LoadError
39
- false
15
+ Dir[File.join(APPSIGNAL_SPEC_DIR, 'support/helpers', '*.rb')].each do |f|
16
+ require f
40
17
  end
41
-
42
- def running_jruby?
43
- defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
44
- end
45
-
46
- def capistrano_present?
47
- !! Gem.loaded_specs['capistrano']
48
- end
49
-
50
- def capistrano2_present?
51
- capistrano_present? &&
52
- Gem.loaded_specs['capistrano'].version < Gem::Version.new('3.0')
53
- end
54
-
55
- def capistrano3_present?
56
- capistrano_present? &&
57
- Gem.loaded_specs['capistrano'].version >= Gem::Version.new('3.0')
58
- end
59
-
60
- def sequel_present?
61
- require 'sequel'
62
- true
63
- rescue LoadError
64
- false
65
- end
66
-
67
- def resque_present?
68
- require 'resque'
69
- true
70
- rescue LoadError
71
- false
72
- end
73
-
74
- def sinatra_present?
75
- begin
76
- require 'sinatra'
77
- true
78
- rescue LoadError
79
- false
18
+ if DependencyHelper.rails_present?
19
+ Dir[File.join(DirectoryHelper.support_dir, 'rails', '*.rb')].each do |f|
20
+ require f
80
21
  end
81
22
  end
82
-
83
- def padrino_present?
84
- require 'padrino'
85
- true
86
- rescue LoadError
87
- false
88
- end
89
-
90
- def grape_present?
91
- require 'grape'
92
- true
93
- rescue LoadError
94
- false
95
- end
96
-
97
- def webmachine_present?
98
- require 'webmachine'
99
- true
100
- rescue LoadError
101
- false
102
- end
103
-
104
23
  require 'appsignal'
105
24
 
106
- def spec_dir
107
- File.dirname(__FILE__)
108
- end
109
-
110
- def tmp_dir
111
- @tmp_dir ||= File.expand_path('tmp', spec_dir)
112
- end
113
-
114
- def fixtures_dir
115
- @fixtures_dir ||= File.expand_path('support/fixtures', spec_dir)
116
- end
117
-
118
- def helpers_dir
119
- @helpers_dir ||= File.expand_path('support/helpers', spec_dir)
120
- end
121
-
122
- Dir[File.join(helpers_dir, '*.rb')].each { |file| require file }
25
+ puts "Running specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}\n\n"
123
26
 
124
27
  # Add way to clear subscribers between specs
125
28
  module ActiveSupport
@@ -134,19 +37,24 @@ module ActiveSupport
134
37
  end
135
38
 
136
39
  RSpec.configure do |config|
40
+ config.include DirectoryHelper
41
+ config.include StdStreamsHelper
137
42
  config.include ConfigHelpers
138
43
  config.include EnvHelpers
139
- config.include NotificationHelpers
140
44
  config.include TimeHelpers
141
45
  config.include TransactionHelpers
46
+ config.include ApiRequestHelper
47
+ config.include SystemHelpers
48
+ config.extend DependencyHelper
142
49
 
143
50
  config.before :all do
144
51
  FileUtils.rm_rf(tmp_dir)
145
52
  FileUtils.mkdir_p(tmp_dir)
146
- end
147
53
 
148
- config.after do
149
- Thread.current[:appsignal_transaction] = nil
54
+ # Use modifiable SYSTEM_TMP_DIR
55
+ Appsignal::Config.send :remove_const, :SYSTEM_TMP_DIR
56
+ Appsignal::Config.send :const_set, :SYSTEM_TMP_DIR,
57
+ File.join(tmp_dir, 'system-tmp')
150
58
  end
151
59
 
152
60
  config.before do
@@ -159,13 +67,13 @@ RSpec.configure do |config|
159
67
  end
160
68
  end
161
69
 
70
+ config.after do
71
+ Thread.current[:appsignal_transaction] = nil
72
+ end
73
+
162
74
  config.after :all do
163
- ActiveSupport::Notifications.notifier.clear_subscribers
164
75
  FileUtils.rm_f(File.join(project_fixture_path, 'log/appsignal.log'))
165
76
  Appsignal.config = nil
166
77
  Appsignal.logger = nil
167
78
  end
168
79
  end
169
-
170
- class VerySpecificError < RuntimeError
171
- end