appsignal 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -1
  3. data/CHANGELOG.md +9 -0
  4. data/benchmark.rake +0 -4
  5. data/lib/appsignal/cli/diagnose.rb +4 -3
  6. data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
  7. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -2
  8. data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -0
  9. data/lib/appsignal/version.rb +1 -1
  10. data/spec/lib/appsignal/auth_check_spec.rb +0 -2
  11. data/spec/lib/appsignal/capistrano2_spec.rb +40 -4
  12. data/spec/lib/appsignal/capistrano3_spec.rb +1 -3
  13. data/spec/lib/appsignal/cli/diagnose_spec.rb +12 -13
  14. data/spec/lib/appsignal/cli/install_spec.rb +0 -1
  15. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +0 -1
  16. data/spec/lib/appsignal/cli_spec.rb +0 -1
  17. data/spec/lib/appsignal/config_spec.rb +0 -2
  18. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -2
  19. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -2
  20. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -2
  21. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -2
  22. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -2
  23. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -2
  24. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +0 -2
  25. data/spec/lib/appsignal/event_formatter_spec.rb +0 -2
  26. data/spec/lib/appsignal/extension_spec.rb +0 -1
  27. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -2
  28. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -2
  29. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -2
  30. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -2
  31. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -2
  32. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -2
  33. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -2
  34. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -1
  35. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -2
  36. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -2
  37. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +1 -4
  38. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -3
  39. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -2
  40. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -3
  41. data/spec/lib/appsignal/hooks_spec.rb +0 -2
  42. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -1
  43. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -2
  44. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -1
  45. data/spec/lib/appsignal/integrations/object_spec.rb +0 -1
  46. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -2
  47. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -2
  48. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +0 -2
  49. data/spec/lib/appsignal/integrations/resque_spec.rb +1 -3
  50. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -2
  51. data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -2
  52. data/spec/lib/appsignal/marker_spec.rb +0 -2
  53. data/spec/lib/appsignal/minutely_spec.rb +0 -2
  54. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -2
  55. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -2
  56. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -2
  57. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +24 -2
  58. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +3 -4
  59. data/spec/lib/appsignal/subscriber_spec.rb +0 -2
  60. data/spec/lib/appsignal/transaction_spec.rb +0 -2
  61. data/spec/lib/appsignal/transmitter_spec.rb +0 -2
  62. data/spec/lib/appsignal/update_active_support_spec.rb +0 -2
  63. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +0 -2
  64. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -2
  65. data/spec/lib/appsignal/utils_spec.rb +0 -2
  66. data/spec/lib/appsignal_spec.rb +2 -3
  67. data/spec/spec_helper.rb +11 -25
  68. data/spec/support/helpers/directory_helper.rb +17 -0
  69. data/spec/support/helpers/very_specific_error.rb +8 -0
  70. metadata +7 -5
  71. data/circle.yml +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec2efb96b788112eddc36f06d1a5b08ded6102ec
4
- data.tar.gz: 14c8aea711a79ad90ce04ffce963fe19546f2b84
3
+ metadata.gz: a80bbf4de405c95b2cbca06180e74dba72dd0e56
4
+ data.tar.gz: 43b9f3679d47469adfc74355f5589849355e84d2
5
5
  SHA512:
6
- metadata.gz: c452757e1ac4c4db326810f1b2ed014fd5d185edde76eab088bd5ca761a90b1de532fde1807cd46bb9eba7c431ea3c2f3a0201a43644b4f966d0e934971d0b05
7
- data.tar.gz: 513c9907c8be8a26f07ef98d34f5840567e7bfdf4243f3dab6fdc88cea9e9b247ec6949459bca60cb9c6509544c95763f7347193532360f149872386f35eabd4
6
+ metadata.gz: 69f92345497c592f802d91d97f407b87f4cf73ad3fe79f8bacbb6ee0dbb0e01e58656b01c52715592b29722be8e4fdb0d55f2b7c41918b9691769d7c602f882c
7
+ data.tar.gz: e2b37a993766b1538de718e2a395f92c771552c4093148d2974fe2c249d1c4dfc733b4dfbe4620cee85a9e45c40deaafc5ced69355028f2a21ae18ebf56c5eea
data/.rspec CHANGED
@@ -1 +1,3 @@
1
- --order default --warnings
1
+ --order default
2
+ --warnings
3
+ --require spec_helper
@@ -1,3 +1,10 @@
1
+ # 1.3.3
2
+
3
+ * Output AppSignal environment on `appsignal diagnose`
4
+ * Prevent transaction crashes on Sinatra routes with optional parameters
5
+ * Listen to `stage` option to Capistrano 2 for automatic environment detection
6
+ * Add `appsignal_env` option to Capistrano 2 to set a custom environment
7
+
1
8
  # 1.3.2
2
9
  * Add method to discard a transaction
3
10
  * Run spec suite with warnings, fixes for warnings
@@ -23,6 +30,8 @@
23
30
  * Allow overriding Padrino environment with APPSIGNAL_APP_ENV
24
31
  * Add mkmf.log to diagnose command
25
32
  * Allow for local install with bundler `bundle exec rake install`
33
+ * Listen to `stage` option to Capistrano 3 for automatic environment detection
34
+ * Add `appsignal_env` option to Capistrano 3 to set a custom environment
26
35
 
27
36
  # 1.2.5
28
37
  * Bugfix in CPU utilization calculation for host metrics
@@ -1,10 +1,6 @@
1
1
  require 'appsignal'
2
2
  require 'benchmark'
3
3
 
4
- class ::Appsignal::EventFormatter::ActiveRecord::SqlFormatter
5
- def connection_config; {:adapter => 'mysql'}; end
6
- end
7
-
8
4
  GC.disable
9
5
 
10
6
  task :default => :'benchmark:all'
@@ -26,6 +26,7 @@ module Appsignal
26
26
 
27
27
  def config
28
28
  start_appsignal
29
+ puts "Environment: #{Appsignal.config.env}"
29
30
  Appsignal.config.config_hash.each do |key, val|
30
31
  puts "Config #{key}: #{val}"
31
32
  end
@@ -60,12 +61,12 @@ module Appsignal
60
61
  def check_ext_install
61
62
  require 'bundler/cli'
62
63
  require "bundler/cli/common"
63
- path = Bundler::CLI::Common.select_spec('appsignal').full_gem_path
64
- install_log_path = "#{path.strip}/ext/install.log"
64
+ path = Bundler::CLI::Common.select_spec('appsignal').full_gem_path.strip
65
+ install_log_path = "#{path}/ext/install.log"
65
66
  puts "Showing last lines of extension install log: #{install_log_path}"
66
67
  puts File.read(install_log_path)
67
68
  puts "\n"
68
- mkmf_log_path = "#{path.strip}/ext/mkmf.log"
69
+ mkmf_log_path = "#{path}/ext/mkmf.log"
69
70
  if File.exist?(mkmf_log_path)
70
71
  puts "Showing last lines of extension compilation log: #{mkmf_log_path}"
71
72
  puts File.read(mkmf_log_path)
@@ -20,7 +20,7 @@ namespace :appsignal do
20
20
  marker = Appsignal::Marker.new(marker_data, appsignal_config)
21
21
  marker.transmit
22
22
  else
23
- puts 'Not notifying of deploy, config is not active'
23
+ puts "Not notifying of deploy, config is not active for environment: #{env}"
24
24
  end
25
25
  end
26
26
  end
@@ -7,7 +7,7 @@ module Appsignal
7
7
 
8
8
  namespace :appsignal do
9
9
  task :deploy do
10
- env = fetch(:rails_env, fetch(:rack_env, 'production'))
10
+ env = fetch(:appsignal_env, fetch(:stage, fetch(:rails_env, fetch(:rack_env, 'production'))))
11
11
  user = ENV['USER'] || ENV['USERNAME']
12
12
  revision = fetch(:appsignal_revision, fetch(:current_revision))
13
13
 
@@ -31,7 +31,7 @@ module Appsignal
31
31
  marker.transmit
32
32
  end
33
33
  else
34
- puts 'Not notifying of deploy, config is not active'
34
+ puts "Not notifying of deploy, config is not active for environment: #{env}"
35
35
  end
36
36
  end
37
37
  end
@@ -73,6 +73,8 @@ module Appsignal
73
73
  end
74
74
 
75
75
  def action_name(env)
76
+ return unless env['sinatra.route']
77
+
76
78
  if @options.fetch(:mounted_at, nil)
77
79
  method, route = env['sinatra.route'].split(" ")
78
80
  "#{method} #{@options[:mounted_at]}#{route}"
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Appsignal
4
- VERSION = '1.3.2'
4
+ VERSION = '1.3.3'
5
5
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::AuthCheck do
4
2
  let(:config) { project_fixture_config }
5
3
  let(:logger) { Logger.new(StringIO.new) }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if capistrano2_present?
4
2
  require 'capistrano'
5
3
  require 'capistrano/configuration'
@@ -81,9 +79,47 @@ if capistrano2_present?
81
79
  )
82
80
  end
83
81
  end
82
+
83
+ context "when stage is used instead of rack_env / rails_env" do
84
+ before do
85
+ @capistrano_config.unset(:rails_env)
86
+ @capistrano_config.set(:stage, 'stage_production')
87
+ end
88
+
89
+ it "should be instantiated with the right params" do
90
+ Appsignal::Config.should_receive(:new).with(
91
+ project_fixture_path,
92
+ 'stage_production',
93
+ {:name => 'AppName'},
94
+ kind_of(Logger)
95
+ )
96
+ end
97
+ end
98
+
99
+ context "when appsignal_env is set" do
100
+ before do
101
+ @capistrano_config.set(:rack_env, 'rack_production')
102
+ @capistrano_config.set(:stage, 'stage_production')
103
+ @capistrano_config.set(:appsignal_env, 'appsignal_production')
104
+ end
105
+
106
+ it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
107
+ Appsignal::Config.should_receive(:new).with(
108
+ project_fixture_path,
109
+ 'appsignal_production',
110
+ {:name => 'AppName'},
111
+ kind_of(Logger)
112
+ )
113
+ end
114
+ end
84
115
  end
85
116
 
86
- after { @capistrano_config.find_and_execute_task('appsignal:deploy') }
117
+ after do
118
+ @capistrano_config.find_and_execute_task('appsignal:deploy')
119
+ @capistrano_config.unset(:stage)
120
+ @capistrano_config.unset(:rack_env)
121
+ @capistrano_config.unset(:appsignal_env)
122
+ end
87
123
  end
88
124
 
89
125
  context "send marker" do
@@ -168,7 +204,7 @@ if capistrano2_present?
168
204
  it "should not send deploy marker" do
169
205
  Appsignal::Marker.should_not_receive(:new)
170
206
  @capistrano_config.find_and_execute_task('appsignal:deploy')
171
- out_stream.string.should include('Not notifying of deploy, config is not active')
207
+ out_stream.string.should include('Not notifying of deploy, config is not active for environment: nonsense')
172
208
  end
173
209
  end
174
210
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if capistrano3_present?
4
2
  require 'capistrano/all'
5
3
  require 'capistrano/deploy'
@@ -198,7 +196,7 @@ if capistrano3_present?
198
196
  it "should not send deploy marker" do
199
197
  Appsignal::Marker.should_not_receive(:new)
200
198
  invoke('appsignal:deploy')
201
- out_stream.string.should include("Not notifying of deploy, config is not active")
199
+ out_stream.string.should include("Not notifying of deploy, config is not active for environment: nonsense")
202
200
  end
203
201
  end
204
202
  end
@@ -1,27 +1,26 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/cli'
3
2
 
4
3
  describe Appsignal::CLI::Diagnose do
5
4
  let(:out_stream) { StringIO.new }
6
5
  let(:cli) { Appsignal::CLI::Diagnose }
7
- before do
8
- @original_stdout = $stdout
6
+ around do |example|
7
+ original_stdout = $stdout
9
8
  $stdout = out_stream
10
- end
11
- after do
12
- $stdout = @original_stdout
9
+ example.run
10
+ $stdout = original_stdout
13
11
  end
14
12
 
15
13
  describe ".run" do
16
14
  it "should output diagnostic information" do
17
15
  cli.run
18
-
19
- out_stream.string.should include('Gem version')
20
- out_stream.string.should include('Agent version')
21
- out_stream.string.should include('Config')
22
- out_stream.string.should include('Checking API key')
23
- out_stream.string.should include('Checking if required paths are writable')
24
- out_stream.string.should include('Showing last lines of extension install log')
16
+ output = out_stream.string
17
+ expect(output).to include('Gem version')
18
+ expect(output).to include('Agent version')
19
+ expect(output).to include('Environment')
20
+ expect(output).to include('Config')
21
+ expect(output).to include('Checking API key')
22
+ expect(output).to include('Checking if required paths are writable')
23
+ expect(output).to include('Showing last lines of extension install log')
25
24
  end
26
25
  end
27
26
  end
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/cli'
3
2
 
4
3
  begin
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/cli'
3
2
 
4
3
  describe Appsignal::CLI::NotifyOfDeploy do
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/cli'
3
2
 
4
3
  describe Appsignal::CLI do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Config do
4
2
  subject { config }
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if rails_present?
4
2
  require 'action_view'
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ActiveRecord::SqlFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ElasticSearch::SearchFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::Faraday::RequestFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::Faraday::RequestFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
4
2
  let(:formatter) { Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter }
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::Moped::QueryFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::Moped::QueryFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class MockFormatter < Appsignal::EventFormatter
4
2
  register 'mock'
5
3
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'fileutils'
3
2
 
4
3
  describe "extension loading and operation" do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::CelluloidHook do
4
2
  context "with celluloid" do
5
3
  before :all do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::DataMapperHook do
4
2
  context "with datamapper" do
5
3
  before :all do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::DelayedJobHook do
4
2
  context "with delayed job" do
5
3
  before(:all) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::MongoRubyDriverHook do
4
2
  require 'appsignal/integrations/mongo_ruby_driver'
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::NetHttpHook do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::PassengerHook do
4
2
  context "with passenger" do
5
3
  before(:all) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::PumaHook do
4
2
  context "with puma" do
5
3
  before(:all) do
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'rake'
3
2
 
4
3
  describe Appsignal::Hooks::RakeHook do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::RedisHook do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::SequelHook, if: sequel_present? do
4
2
  let(:db) { Sequel.sqlite }
5
3
 
@@ -1,6 +1,3 @@
1
- require 'spec_helper'
2
-
3
-
4
1
  describe Appsignal::Hooks::ShoryukenMiddleware do
5
2
  let(:current_transaction) { background_job_transaction }
6
3
 
@@ -51,7 +48,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
51
48
  end
52
49
 
53
50
  context "with an erroring call" do
54
- let(:error) { VerySpecificError.new('on fire') }
51
+ let(:error) { VerySpecificError.new }
55
52
 
56
53
  it "should add the exception to appsignal" do
57
54
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::SidekiqPlugin do
4
2
  let(:worker) { double }
5
3
  let(:queue) { double }
@@ -79,7 +77,8 @@ describe Appsignal::Hooks::SidekiqPlugin do
79
77
  end
80
78
 
81
79
  context "with an erroring call" do
82
- let(:error) { VerySpecificError.new('the roof') }
80
+ let(:error) { VerySpecificError.new }
81
+
83
82
  it "should add the exception to appsignal" do
84
83
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
85
84
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::UnicornHook do
4
2
  context "with unicorn" do
5
3
  before :all do
@@ -1,7 +1,4 @@
1
- require 'spec_helper'
2
-
3
1
  if webmachine_present?
4
-
5
2
  describe Appsignal::Hooks::WebmachineHook do
6
3
  context "with webmachine" do
7
4
  before(:all) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class MockPresentHook < Appsignal::Hooks::Hook
4
2
  def dependencies_present?
5
3
  true
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/data_mapper'
3
2
 
4
3
  describe Appsignal::Hooks::DataMapperLogListener do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if grape_present?
4
2
  require 'appsignal/integrations/grape'
5
3
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/mongo_ruby_driver'
3
2
  describe Appsignal::Hooks::MongoMonitorSubscriber do
4
3
  let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/object'
3
2
 
4
3
  describe Object do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  begin
4
2
  require 'padrino'
5
3
  rescue LoadError
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if rails_present?
4
2
  describe Appsignal::Integrations::Railtie do
5
3
  context "after initializing the app" do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if resque_present? && active_job_present?
4
2
  describe "Resque ActiveJob integration" do
5
3
  let(:file) { File.expand_path('lib/appsignal/integrations/resque_active_job.rb') }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if resque_present?
4
2
  describe "Resque integration" do
5
3
  let(:file) { File.expand_path('lib/appsignal/integrations/resque.rb') }
@@ -20,7 +18,7 @@ if resque_present?
20
18
  extend Appsignal::Integrations::ResquePlugin
21
19
 
22
20
  def self.perform
23
- raise VerySpecificError.new('broken')
21
+ raise VerySpecificError.new
24
22
  end
25
23
  end
26
24
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  if sinatra_present? && !padrino_present?
4
2
  ENV['APPSIGNAL_PUSH_API_KEY'] = 'key'
5
3
  require 'appsignal/integrations/sinatra'
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::JSExceptionTransaction do
4
2
  before { SecureRandom.stub(:uuid => '123abc') }
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Marker do
4
2
  let(:config) { project_fixture_config }
5
3
  let(:marker) {
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Minutely do
4
2
  before do
5
3
  Appsignal::Minutely.probes.clear
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Rack::GenericInstrumentation do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Rack::JSExceptionCatcher do
4
2
  let(:app) { double(:call => true) }
5
3
  let(:options) { double }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class MockController
4
2
  end
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  begin
4
2
  require 'sinatra'
5
3
  require 'appsignal/integrations/sinatra'
@@ -133,12 +131,28 @@ if defined?(::Sinatra)
133
131
  Appsignal::Transaction.any_instance.should_receive(:set_action).with('GET /')
134
132
  end
135
133
 
134
+ context "without 'sinatra.route' env" do
135
+ let(:env) { {:path => '/', :method => 'GET'} }
136
+
137
+ it "returns nil" do
138
+ Appsignal::Transaction.any_instance.should_receive(:set_action).with(nil)
139
+ end
140
+ end
141
+
136
142
  context "with option to set path a mounted_at prefix" do
137
143
  let(:options) {{ :mounted_at => "/api/v2" }}
138
144
 
139
145
  it "should call set_action with a prefix path" do
140
146
  Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/v2/")
141
147
  end
148
+
149
+ context "without 'sinatra.route' env" do
150
+ let(:env) { {:path => '/', :method => 'GET'} }
151
+
152
+ it "returns nil" do
153
+ Appsignal::Transaction.any_instance.should_receive(:set_action).with(nil)
154
+ end
155
+ end
142
156
  end
143
157
 
144
158
  context "with mounted modular application" do
@@ -147,6 +161,14 @@ if defined?(::Sinatra)
147
161
  it "should call set_action with an application prefix path" do
148
162
  Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/")
149
163
  end
164
+
165
+ context "without 'sinatra.route' env" do
166
+ let(:env) { {:path => '/', :method => 'GET'} }
167
+
168
+ it "returns nil" do
169
+ Appsignal::Transaction.any_instance.should_receive(:set_action).with(nil)
170
+ end
171
+ end
150
172
  end
151
173
  end
152
174
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/rack/streaming_listener'
3
2
 
4
3
  describe Appsignal::Rack::StreamingListener do
@@ -89,7 +88,7 @@ describe Appsignal::Rack::StreamingListener do
89
88
 
90
89
  context "with an exception in the instrumentation call" do
91
90
  it "should add the exception to the transaction" do
92
- allow( app ).to receive(:call).and_raise(VerySpecificError.new('broken'))
91
+ allow( app ).to receive(:call).and_raise(VerySpecificError.new)
93
92
 
94
93
  expect( transaction ).to receive(:set_error)
95
94
 
@@ -124,7 +123,7 @@ describe Appsignal::StreamWrapper do
124
123
  context "when each raises an error" do
125
124
  it "should add the exception to the transaction" do
126
125
  allow( stream ).to receive(:each)
127
- .and_raise(VerySpecificError.new('broken'))
126
+ .and_raise(VerySpecificError.new)
128
127
 
129
128
  expect( transaction ).to receive(:set_error)
130
129
 
@@ -144,7 +143,7 @@ describe Appsignal::StreamWrapper do
144
143
  context "when each raises an error" do
145
144
  it "should add the exception to the transaction and close it" do
146
145
  allow( stream ).to receive(:close)
147
- .and_raise(VerySpecificError.new('broken'))
146
+ .and_raise(VerySpecificError.new)
148
147
 
149
148
  expect( transaction ).to receive(:set_error)
150
149
  expect( Appsignal::Transaction ).to receive(:complete_current!)
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Subscriber do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class Smash < Hash
4
2
  def []=(key, val)
5
3
  raise 'the roof'
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Transmitter do
4
2
  let(:config) { project_fixture_config }
5
3
  let(:action) { 'action' }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe 'Appsignal::UpdateActiveSupport', :if => (
4
2
  Gem.loaded_specs['rails'] &&
5
3
  Gem.loaded_specs['rails'].version < Gem::Version.create('4.0')
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Utils::ParamsSanitizer do
4
2
  let(:file) { uploaded_file }
5
3
  let(:params) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Utils::QueryParamsSanitizer do
4
2
  describe ".sanitize" do
5
3
  context "when only_top_level = true" do
@@ -1,7 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'spec_helper'
4
-
5
3
  describe Appsignal::Utils do
6
4
  describe ".json_generate" do
7
5
  subject { Appsignal::Utils.json_generate(body) }
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require './spec/support/mocks/mock_extension'
3
2
 
4
3
  describe Appsignal do
@@ -361,7 +360,7 @@ describe Appsignal do
361
360
  end
362
361
 
363
362
  context "with an erroring call" do
364
- let(:error) { VerySpecificError.new('the roof') }
363
+ let(:error) { VerySpecificError.new }
365
364
 
366
365
  it "should add the error to the current transaction and complete" do
367
366
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
@@ -392,7 +391,7 @@ describe Appsignal do
392
391
  end
393
392
 
394
393
  context "with an erroring call" do
395
- let(:error) { VerySpecificError.new('the roof') }
394
+ let(:error) { VerySpecificError.new }
396
395
 
397
396
  it "should call monitor_transaction and stop and then raise the error" do
398
397
  Appsignal.should_receive(:monitor_transaction).with(
@@ -1,15 +1,21 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
  ENV['PADRINO_ENV'] ||= 'test'
3
3
 
4
+ APPSIGNAL_SPEC_DIR = File.expand_path(File.dirname(__FILE__))
5
+
4
6
  require 'rack'
5
7
  require 'rspec'
6
8
  require 'pry'
7
9
  require 'timecop'
8
10
  require 'webmock/rspec'
9
11
 
10
- puts "Runnings specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}"
12
+ Dir[File.join(APPSIGNAL_SPEC_DIR, 'support/helpers', '*.rb')].each do |f|
13
+ require f
14
+ end
15
+
16
+ $LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, 'support/stubs'))
11
17
 
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support/stubs'))
18
+ puts "Running specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}\n\n"
13
19
 
14
20
  begin
15
21
  require 'rails'
@@ -21,6 +27,8 @@ rescue LoadError
21
27
  RAILS_PRESENT = false
22
28
  end
23
29
 
30
+ require 'appsignal'
31
+
24
32
  def rails_present?
25
33
  RAILS_PRESENT
26
34
  end
@@ -101,26 +109,6 @@ rescue LoadError
101
109
  false
102
110
  end
103
111
 
104
- require 'appsignal'
105
-
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 }
123
-
124
112
  # Add way to clear subscribers between specs
125
113
  module ActiveSupport
126
114
  module Notifications
@@ -134,6 +122,7 @@ module ActiveSupport
134
122
  end
135
123
 
136
124
  RSpec.configure do |config|
125
+ config.include DirectoryHelper
137
126
  config.include ConfigHelpers
138
127
  config.include EnvHelpers
139
128
  config.include NotificationHelpers
@@ -166,6 +155,3 @@ RSpec.configure do |config|
166
155
  Appsignal.logger = nil
167
156
  end
168
157
  end
169
-
170
- class VerySpecificError < RuntimeError
171
- end
@@ -0,0 +1,17 @@
1
+ module DirectoryHelper
2
+ def spec_dir
3
+ APPSIGNAL_SPEC_DIR
4
+ end
5
+
6
+ def support_dir
7
+ @support_dir ||= File.join(spec_dir, 'support')
8
+ end
9
+
10
+ def tmp_dir
11
+ @tmp_dir ||= File.join(spec_dir, 'tmp')
12
+ end
13
+
14
+ def fixtures_dir
15
+ @fixtures_dir ||= File.join(support_dir, 'fixtures')
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # This VerySpecificError is used for throwing errors in specs that are allowed
2
+ # or expected.
3
+ #
4
+ # For example, this error can be thrown to raise an exception in AppSignal's
5
+ # run, which should stop the program and the appsignal gem, but not crash the
6
+ # test suite.
7
+ class VerySpecificError < RuntimeError
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-01 00:00:00.000000000 Z
12
+ date: 2016-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -129,7 +129,6 @@ files:
129
129
  - appsignal.gemspec
130
130
  - benchmark.rake
131
131
  - bin/appsignal
132
- - circle.yml
133
132
  - ext/agent.yml
134
133
  - ext/appsignal_extension.c
135
134
  - ext/extconf.rb
@@ -283,10 +282,12 @@ files:
283
282
  - spec/support/fixtures/generated_config.yml
284
283
  - spec/support/fixtures/uploaded_file.txt
285
284
  - spec/support/helpers/config_helpers.rb
285
+ - spec/support/helpers/directory_helper.rb
286
286
  - spec/support/helpers/env_helpers.rb
287
287
  - spec/support/helpers/notification_helpers.rb
288
288
  - spec/support/helpers/time_helpers.rb
289
289
  - spec/support/helpers/transaction_helpers.rb
290
+ - spec/support/helpers/very_specific_error.rb
290
291
  - spec/support/mocks/mock_extension.rb
291
292
  - spec/support/project_fixture/config/application.rb
292
293
  - spec/support/project_fixture/config/appsignal.yml
@@ -317,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
318
  version: '0'
318
319
  requirements: []
319
320
  rubyforge_project:
320
- rubygems_version: 2.4.5
321
+ rubygems_version: 2.5.1
321
322
  signing_key:
322
323
  specification_version: 4
323
324
  summary: Logs performance and exception data from your app to appsignal.com
@@ -386,10 +387,12 @@ test_files:
386
387
  - spec/support/fixtures/generated_config.yml
387
388
  - spec/support/fixtures/uploaded_file.txt
388
389
  - spec/support/helpers/config_helpers.rb
390
+ - spec/support/helpers/directory_helper.rb
389
391
  - spec/support/helpers/env_helpers.rb
390
392
  - spec/support/helpers/notification_helpers.rb
391
393
  - spec/support/helpers/time_helpers.rb
392
394
  - spec/support/helpers/transaction_helpers.rb
395
+ - spec/support/helpers/very_specific_error.rb
393
396
  - spec/support/mocks/mock_extension.rb
394
397
  - spec/support/project_fixture/config/application.rb
395
398
  - spec/support/project_fixture/config/appsignal.yml
@@ -399,4 +402,3 @@ test_files:
399
402
  - spec/support/project_fixture/log/.gitkeep
400
403
  - spec/support/rails/my_app.rb
401
404
  - spec/support/stubs/delayed_job.rb
402
- has_rdoc:
data/circle.yml DELETED
@@ -1,12 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.3.0
4
-
5
- dependencies:
6
- override:
7
- - bundle
8
- - bundle exec rake generate_bundle_and_spec_all
9
-
10
- test:
11
- override:
12
- - ./bundle_and_spec_all_rvm