appsignal 2.1.0.alpha.3 → 2.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +43 -0
  4. data/.rubocop_todo.yml +289 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +11 -1
  7. data/Gemfile +1 -1
  8. data/LICENSE +1 -1
  9. data/appsignal.gemspec +1 -0
  10. data/bin/appsignal +2 -2
  11. data/ext/agent.yml +11 -11
  12. data/ext/extconf.rb +33 -33
  13. data/gemfiles/rails-4.2.gemfile +4 -0
  14. data/gemfiles/resque.gemfile +4 -0
  15. data/lib/appsignal.rb +58 -54
  16. data/lib/appsignal/auth_check.rb +15 -16
  17. data/lib/appsignal/capistrano.rb +4 -4
  18. data/lib/appsignal/cli.rb +28 -28
  19. data/lib/appsignal/cli/diagnose.rb +11 -11
  20. data/lib/appsignal/cli/helpers.rb +1 -1
  21. data/lib/appsignal/cli/install.rb +38 -38
  22. data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
  23. data/lib/appsignal/config.rb +73 -71
  24. data/lib/appsignal/event_formatter.rb +8 -8
  25. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +4 -4
  26. data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
  27. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
  28. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +9 -7
  29. data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
  30. data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +6 -6
  31. data/lib/appsignal/event_formatter/moped/query_formatter.rb +56 -43
  32. data/lib/appsignal/extension.rb +5 -5
  33. data/lib/appsignal/hooks.rb +28 -26
  34. data/lib/appsignal/hooks/active_support_notifications.rb +2 -2
  35. data/lib/appsignal/hooks/celluloid.rb +1 -1
  36. data/lib/appsignal/hooks/data_mapper.rb +2 -2
  37. data/lib/appsignal/hooks/delayed_job.rb +1 -1
  38. data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
  39. data/lib/appsignal/hooks/net_http.rb +4 -4
  40. data/lib/appsignal/hooks/passenger.rb +2 -2
  41. data/lib/appsignal/hooks/puma.rb +4 -4
  42. data/lib/appsignal/hooks/rake.rb +1 -1
  43. data/lib/appsignal/hooks/redis.rb +1 -1
  44. data/lib/appsignal/hooks/sequel.rb +2 -2
  45. data/lib/appsignal/hooks/shoryuken.rb +8 -8
  46. data/lib/appsignal/hooks/sidekiq.rb +16 -15
  47. data/lib/appsignal/hooks/unicorn.rb +1 -1
  48. data/lib/appsignal/hooks/webmachine.rb +1 -1
  49. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +6 -6
  50. data/lib/appsignal/integrations/data_mapper.rb +2 -3
  51. data/lib/appsignal/integrations/delayed_job_plugin.rb +5 -5
  52. data/lib/appsignal/integrations/mongo_ruby_driver.rb +6 -6
  53. data/lib/appsignal/integrations/padrino.rb +8 -8
  54. data/lib/appsignal/integrations/railtie.rb +5 -5
  55. data/lib/appsignal/integrations/resque.rb +4 -5
  56. data/lib/appsignal/integrations/resque_active_job.rb +3 -6
  57. data/lib/appsignal/integrations/sinatra.rb +2 -2
  58. data/lib/appsignal/integrations/webmachine.rb +2 -3
  59. data/lib/appsignal/js_exception_transaction.rb +10 -10
  60. data/lib/appsignal/marker.rb +3 -3
  61. data/lib/appsignal/rack/generic_instrumentation.rb +10 -9
  62. data/lib/appsignal/rack/js_exception_catcher.rb +7 -6
  63. data/lib/appsignal/rack/rails_instrumentation.rb +9 -8
  64. data/lib/appsignal/rack/sinatra_instrumentation.rb +19 -17
  65. data/lib/appsignal/rack/streaming_listener.rb +9 -8
  66. data/lib/appsignal/system.rb +19 -17
  67. data/lib/appsignal/transaction.rb +97 -40
  68. data/lib/appsignal/transmitter.rb +23 -30
  69. data/lib/appsignal/utils.rb +3 -3
  70. data/lib/appsignal/utils/params_sanitizer.rb +1 -1
  71. data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
  72. data/lib/appsignal/version.rb +2 -2
  73. data/spec/.rubocop.yml +4 -0
  74. data/spec/lib/appsignal/auth_check_spec.rb +7 -7
  75. data/spec/lib/appsignal/capistrano2_spec.rb +41 -41
  76. data/spec/lib/appsignal/capistrano3_spec.rb +43 -44
  77. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +9 -11
  78. data/spec/lib/appsignal/cli_spec.rb +9 -9
  79. data/spec/lib/appsignal/config_spec.rb +88 -86
  80. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +9 -9
  81. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +4 -4
  82. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +4 -4
  83. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +12 -12
  84. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +4 -4
  85. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +23 -23
  86. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +29 -30
  87. data/spec/lib/appsignal/event_formatter_spec.rb +28 -28
  88. data/spec/lib/appsignal/extension_spec.rb +15 -15
  89. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +6 -5
  90. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +12 -12
  91. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +34 -34
  92. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -3
  93. data/spec/lib/appsignal/hooks/net_http_spec.rb +10 -10
  94. data/spec/lib/appsignal/hooks/rake_spec.rb +7 -7
  95. data/spec/lib/appsignal/hooks/redis_spec.rb +6 -6
  96. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +21 -22
  97. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +48 -45
  98. data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -2
  99. data/spec/lib/appsignal/hooks_spec.rb +16 -17
  100. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +7 -8
  101. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +19 -19
  102. data/spec/lib/appsignal/integrations/object_spec.rb +3 -3
  103. data/spec/lib/appsignal/integrations/padrino_spec.rb +44 -44
  104. data/spec/lib/appsignal/integrations/railtie_spec.rb +13 -13
  105. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +7 -7
  106. data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
  107. data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -7
  108. data/spec/lib/appsignal/integrations/webmachine_spec.rb +15 -15
  109. data/spec/lib/appsignal/js_exception_transaction_spec.rb +23 -23
  110. data/spec/lib/appsignal/marker_spec.rb +8 -8
  111. data/spec/lib/appsignal/minutely_spec.rb +6 -6
  112. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -7
  113. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +13 -13
  114. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +11 -11
  115. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
  116. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +36 -36
  117. data/spec/lib/appsignal/system/container_spec.rb +1 -1
  118. data/spec/lib/appsignal/transaction_spec.rb +213 -184
  119. data/spec/lib/appsignal/transmitter_spec.rb +20 -20
  120. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +19 -19
  121. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +41 -41
  122. data/spec/lib/appsignal/utils_spec.rb +41 -37
  123. data/spec/lib/appsignal_spec.rb +150 -142
  124. data/spec/spec_helper.rb +18 -18
  125. data/spec/support/delegate_matcher.rb +6 -6
  126. data/spec/support/helpers/api_request_helper.rb +2 -2
  127. data/spec/support/helpers/config_helpers.rb +3 -3
  128. data/spec/support/helpers/dependency_helper.rb +13 -13
  129. data/spec/support/helpers/directory_helper.rb +5 -5
  130. data/spec/support/helpers/env_helpers.rb +14 -14
  131. data/spec/support/helpers/system_helpers.rb +3 -3
  132. data/spec/support/helpers/transaction_helpers.rb +10 -10
  133. metadata +20 -2
@@ -1,13 +1,13 @@
1
- require 'net/http'
2
- require 'net/https'
3
- require 'uri'
4
- require 'rack/utils'
5
- require 'json'
1
+ require "net/http"
2
+ require "net/https"
3
+ require "uri"
4
+ require "rack/utils"
5
+ require "json"
6
6
 
7
7
  module Appsignal
8
8
  class Transmitter
9
- CONTENT_TYPE = 'application/json; charset=UTF-8'.freeze
10
- CONTENT_ENCODING = 'gzip'.freeze
9
+ CONTENT_TYPE = "application/json; charset=UTF-8".freeze
10
+ CONTENT_ENCODING = "gzip".freeze
11
11
 
12
12
  HTTP_ERRORS = [
13
13
  EOFError,
@@ -23,20 +23,18 @@ module Appsignal
23
23
 
24
24
  attr_reader :config, :action
25
25
 
26
- def initialize(action, config=Appsignal.config)
26
+ def initialize(action, config = Appsignal.config)
27
27
  @action = action
28
28
  @config = config
29
29
  end
30
30
 
31
31
  def uri
32
32
  @uri ||= URI("#{config[:endpoint]}/1/#{action}").tap do |uri|
33
- uri.query = ::Rack::Utils.build_query({
34
- :api_key => config[:push_api_key],
33
+ uri.query = ::Rack::Utils.build_query(:api_key => config[:push_api_key],
35
34
  :name => config[:name],
36
35
  :environment => config.env,
37
36
  :hostname => config[:hostname],
38
- :gem_version => Appsignal::VERSION
39
- })
37
+ :gem_version => Appsignal::VERSION)
40
38
  end
41
39
  end
42
40
 
@@ -49,22 +47,23 @@ module Appsignal
49
47
 
50
48
  def http_post(payload)
51
49
  Net::HTTP::Post.new(uri.request_uri).tap do |request|
52
- request['Content-Type'] = CONTENT_TYPE
53
- request['Content-Encoding'] = CONTENT_ENCODING
50
+ request["Content-Type"] = CONTENT_TYPE
51
+ request["Content-Encoding"] = CONTENT_ENCODING
54
52
  request.body = Appsignal::Utils::Gzip.compress \
55
53
  Appsignal::Utils::JSON.generate(payload)
56
54
  end
57
55
  end
58
56
 
59
57
  def http_client
60
- client = if config[:http_proxy]
61
- Net::HTTP.new(uri.host, uri.port, proxy_addr, proxy_port)
62
- else
63
- Net::HTTP.new(uri.host, uri.port)
64
- end
58
+ client =
59
+ if config[:http_proxy]
60
+ Net::HTTP.new(uri.host, uri.port, proxy_addr, proxy_port)
61
+ else
62
+ Net::HTTP.new(uri.host, uri.port)
63
+ end
65
64
 
66
65
  client.tap do |http|
67
- if uri.scheme == 'https'
66
+ if uri.scheme == "https"
68
67
  http.use_ssl = true
69
68
  http.ssl_version = :TLSv1
70
69
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@@ -85,19 +84,13 @@ module Appsignal
85
84
  end
86
85
 
87
86
  def proxy_addr
88
- if config[:http_proxy]
89
- proxy_uri.host
90
- else
91
- nil
92
- end
87
+ return unless config[:http_proxy]
88
+ proxy_uri.host
93
89
  end
94
90
 
95
91
  def proxy_port
96
- if config[:http_proxy]
97
- proxy_uri.port
98
- else
99
- nil
100
- end
92
+ return unless config[:http_proxy]
93
+ proxy_uri.port
101
94
  end
102
95
  end
103
96
  end
@@ -1,5 +1,5 @@
1
- require 'appsignal/utils/params_sanitizer'
2
- require 'appsignal/utils/query_params_sanitizer'
1
+ require "appsignal/utils/params_sanitizer"
2
+ require "appsignal/utils/query_params_sanitizer"
3
3
 
4
4
  module Appsignal
5
5
  module Utils
@@ -101,7 +101,7 @@ module Appsignal
101
101
 
102
102
  def encode_utf8(value)
103
103
  value.encode(
104
- 'utf-8'.freeze,
104
+ "utf-8".freeze,
105
105
  :invalid => :replace,
106
106
  :undef => :replace
107
107
  )
@@ -1,7 +1,7 @@
1
1
  module Appsignal
2
2
  module Utils
3
3
  class ParamsSanitizer
4
- FILTERED = '[FILTERED]'.freeze
4
+ FILTERED = "[FILTERED]".freeze
5
5
 
6
6
  class << self
7
7
  def sanitize(params, options = {})
@@ -1,7 +1,7 @@
1
1
  module Appsignal
2
2
  module Utils
3
3
  class QueryParamsSanitizer
4
- REPLACEMENT_KEY = '?'.freeze
4
+ REPLACEMENT_KEY = "?".freeze
5
5
 
6
6
  module ClassMethods
7
7
  def sanitize(params, only_top_level = false, key_sanitizer = nil)
@@ -1,5 +1,5 @@
1
- require 'yaml'
1
+ require "yaml"
2
2
 
3
3
  module Appsignal
4
- VERSION = '2.1.0.alpha.3'
4
+ VERSION = "2.1.0.beta.1"
5
5
  end
@@ -0,0 +1,4 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ # Metrics/LineLength:
4
+ # Max: 100
@@ -5,18 +5,18 @@ describe Appsignal::AuthCheck do
5
5
 
6
6
  describe "#perform_with_result" do
7
7
  it "should give success message" do
8
- auth_check.should_receive(:perform).and_return('200')
9
- auth_check.perform_with_result.should eq ['200', 'AppSignal has confirmed authorization!']
8
+ auth_check.should_receive(:perform).and_return("200")
9
+ auth_check.perform_with_result.should eq ["200", "AppSignal has confirmed authorization!"]
10
10
  end
11
11
 
12
12
  it "should give 401 message" do
13
- auth_check.should_receive(:perform).and_return('401')
14
- auth_check.perform_with_result.should eq ['401', 'API key not valid with AppSignal...']
13
+ auth_check.should_receive(:perform).and_return("401")
14
+ auth_check.perform_with_result.should eq ["401", "API key not valid with AppSignal..."]
15
15
  end
16
16
 
17
17
  it "should give an error message" do
18
- auth_check.should_receive(:perform).and_return('402')
19
- auth_check.perform_with_result.should eq ['402', 'Could not confirm authorization: 402']
18
+ auth_check.should_receive(:perform).and_return("402")
19
+ auth_check.perform_with_result.should eq ["402", "Could not confirm authorization: 402"]
20
20
  end
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ describe Appsignal::AuthCheck do
24
24
  before do
25
25
  @transmitter = double
26
26
  Appsignal::Transmitter.should_receive(:new).with(
27
- 'auth',
27
+ "auth",
28
28
  kind_of(Appsignal::Config)
29
29
  ).and_return(@transmitter)
30
30
  end
@@ -1,7 +1,7 @@
1
1
  if DependencyHelper.capistrano2_present?
2
- require 'capistrano'
3
- require 'capistrano/configuration'
4
- require 'appsignal/capistrano'
2
+ require "capistrano"
3
+ require "capistrano/configuration"
4
+ require "appsignal/capistrano"
5
5
 
6
6
  describe "Capistrano 2 integration" do
7
7
  let(:out_stream) { std_stream }
@@ -9,11 +9,11 @@ if DependencyHelper.capistrano2_present?
9
9
  let(:config) { project_fixture_config }
10
10
  let(:capistrano_config) do
11
11
  Capistrano::Configuration.new.tap do |c|
12
- c.set(:rails_env, 'production')
13
- c.set(:repository, 'master')
14
- c.set(:deploy_to, '/home/username/app')
15
- c.set(:current_release, '')
16
- c.set(:current_revision, '503ce0923ed177a3ce000005')
12
+ c.set(:rails_env, "production")
13
+ c.set(:repository, "master")
14
+ c.set(:deploy_to, "/home/username/app")
15
+ c.set(:current_release, "")
16
+ c.set(:current_revision, "503ce0923ed177a3ce000005")
17
17
  c.dry_run = false
18
18
  end
19
19
  end
@@ -21,18 +21,18 @@ if DependencyHelper.capistrano2_present?
21
21
 
22
22
  def run
23
23
  capture_stdout(out_stream) do
24
- capistrano_config.find_and_execute_task('appsignal:deploy')
24
+ capistrano_config.find_and_execute_task("appsignal:deploy")
25
25
  end
26
26
  end
27
27
 
28
28
  it "should have a deploy task" do
29
- capistrano_config.find_task('appsignal:deploy').should_not be_nil
29
+ capistrano_config.find_task("appsignal:deploy").should_not be_nil
30
30
  end
31
31
 
32
32
  describe "appsignal:deploy task" do
33
33
  before do
34
- ENV['USER'] = 'batman'
35
- ENV['PWD'] = project_fixture_path
34
+ ENV["USER"] = "batman"
35
+ ENV["PWD"] = project_fixture_path
36
36
  end
37
37
 
38
38
  context "config" do
@@ -43,7 +43,7 @@ if DependencyHelper.capistrano2_present?
43
43
  it "should be instantiated with the right params" do
44
44
  Appsignal::Config.should_receive(:new).with(
45
45
  project_fixture_path,
46
- 'production',
46
+ "production",
47
47
  {},
48
48
  kind_of(Logger)
49
49
  )
@@ -51,14 +51,14 @@ if DependencyHelper.capistrano2_present?
51
51
 
52
52
  context "when appsignal_config is available" do
53
53
  before do
54
- capistrano_config.set(:appsignal_config, :name => 'AppName')
54
+ capistrano_config.set(:appsignal_config, :name => "AppName")
55
55
  end
56
56
 
57
57
  it "should be instantiated with the right params" do
58
58
  Appsignal::Config.should_receive(:new).with(
59
59
  project_fixture_path,
60
- 'production',
61
- {:name => 'AppName'},
60
+ "production",
61
+ { :name => "AppName" },
62
62
  kind_of(Logger)
63
63
  )
64
64
  end
@@ -66,14 +66,14 @@ if DependencyHelper.capistrano2_present?
66
66
  context "when rack_env is used instead of rails_env" do
67
67
  before do
68
68
  capistrano_config.unset(:rails_env)
69
- capistrano_config.set(:rack_env, 'rack_production')
69
+ capistrano_config.set(:rack_env, "rack_production")
70
70
  end
71
71
 
72
72
  it "should be instantiated with the right params" do
73
73
  Appsignal::Config.should_receive(:new).with(
74
74
  project_fixture_path,
75
- 'rack_production',
76
- {:name => 'AppName'},
75
+ "rack_production",
76
+ { :name => "AppName" },
77
77
  kind_of(Logger)
78
78
  )
79
79
  end
@@ -82,14 +82,14 @@ if DependencyHelper.capistrano2_present?
82
82
  context "when stage is used instead of rack_env / rails_env" do
83
83
  before do
84
84
  capistrano_config.unset(:rails_env)
85
- capistrano_config.set(:stage, 'stage_production')
85
+ capistrano_config.set(:stage, "stage_production")
86
86
  end
87
87
 
88
88
  it "should be instantiated with the right params" do
89
89
  Appsignal::Config.should_receive(:new).with(
90
90
  project_fixture_path,
91
- 'stage_production',
92
- {:name => 'AppName'},
91
+ "stage_production",
92
+ { :name => "AppName" },
93
93
  kind_of(Logger)
94
94
  )
95
95
  end
@@ -97,16 +97,16 @@ if DependencyHelper.capistrano2_present?
97
97
 
98
98
  context "when appsignal_env is set" do
99
99
  before do
100
- capistrano_config.set(:rack_env, 'rack_production')
101
- capistrano_config.set(:stage, 'stage_production')
102
- capistrano_config.set(:appsignal_env, 'appsignal_production')
100
+ capistrano_config.set(:rack_env, "rack_production")
101
+ capistrano_config.set(:stage, "stage_production")
102
+ capistrano_config.set(:appsignal_env, "appsignal_production")
103
103
  end
104
104
 
105
105
  it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
106
106
  Appsignal::Config.should_receive(:new).with(
107
107
  project_fixture_path,
108
- 'appsignal_production',
109
- {:name => 'AppName'},
108
+ "appsignal_production",
109
+ { :name => "AppName" },
110
110
  kind_of(Logger)
111
111
  )
112
112
  end
@@ -118,13 +118,13 @@ if DependencyHelper.capistrano2_present?
118
118
 
119
119
  describe "markers" do
120
120
  def stub_marker_request(data = {})
121
- stub_api_request config, 'markers', marker_data.merge(data)
121
+ stub_api_request config, "markers", marker_data.merge(data)
122
122
  end
123
123
 
124
124
  let(:marker_data) do
125
125
  {
126
- :revision => '503ce0923ed177a3ce000005',
127
- :user => 'batman'
126
+ :revision => "503ce0923ed177a3ce000005",
127
+ :user => "batman"
128
128
  }
129
129
  end
130
130
 
@@ -134,21 +134,21 @@ if DependencyHelper.capistrano2_present?
134
134
  run
135
135
 
136
136
  expect(output).to include \
137
- 'Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
138
- 'AppSignal has been notified of this deploy!'
137
+ "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman",
138
+ "AppSignal has been notified of this deploy!"
139
139
  end
140
140
 
141
141
  context "with overridden revision" do
142
142
  before do
143
- capistrano_config.set(:appsignal_revision, 'abc123')
144
- stub_marker_request(:revision => 'abc123').to_return(:status => 200)
143
+ capistrano_config.set(:appsignal_revision, "abc123")
144
+ stub_marker_request(:revision => "abc123").to_return(:status => 200)
145
145
  run
146
146
  end
147
147
 
148
148
  it "transmits the overriden revision" do
149
149
  expect(output).to include \
150
- 'Notifying AppSignal of deploy with: revision: abc123, user: batman',
151
- 'AppSignal has been notified of this deploy!'
150
+ "Notifying AppSignal of deploy with: revision: abc123, user: batman",
151
+ "AppSignal has been notified of this deploy!"
152
152
  end
153
153
  end
154
154
 
@@ -160,9 +160,9 @@ if DependencyHelper.capistrano2_present?
160
160
 
161
161
  it "does not transmit marker" do
162
162
  expect(output).to include \
163
- 'Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
164
- 'Something went wrong while trying to notify AppSignal:'
165
- expect(output).to_not include 'AppSignal has been notified of this deploy!'
163
+ "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman",
164
+ "Something went wrong while trying to notify AppSignal:"
165
+ expect(output).to_not include "AppSignal has been notified of this deploy!"
166
166
  end
167
167
  end
168
168
 
@@ -174,14 +174,14 @@ if DependencyHelper.capistrano2_present?
174
174
 
175
175
  it "does not transmit marker" do
176
176
  expect(output).to include \
177
- 'Dry run: AppSignal deploy marker not actually sent.'
177
+ "Dry run: AppSignal deploy marker not actually sent."
178
178
  end
179
179
  end
180
180
  end
181
181
 
182
182
  context "when not active for this environment" do
183
183
  before do
184
- capistrano_config.set(:rails_env, 'nonsense')
184
+ capistrano_config.set(:rails_env, "nonsense")
185
185
  run
186
186
  end
187
187
 
@@ -1,11 +1,10 @@
1
1
  if DependencyHelper.capistrano3_present?
2
- require 'capistrano/all'
3
- require 'capistrano/deploy'
4
- require 'appsignal/capistrano'
5
-
6
- include Capistrano::DSL
2
+ require "capistrano/all"
3
+ require "capistrano/deploy"
4
+ require "appsignal/capistrano"
7
5
 
8
6
  describe "Capistrano 3 integration" do
7
+ let(:capistrano) { Class.new.extend(Capistrano::DSL) }
9
8
  let(:config) { project_fixture_config }
10
9
  let(:out_stream) { std_stream }
11
10
  let(:output) { out_stream.read }
@@ -15,36 +14,36 @@ if DependencyHelper.capistrano3_present?
15
14
  Capistrano::Configuration.env.tap do |c|
16
15
  c.set(:log_level, :error)
17
16
  c.set(:logger, logger)
18
- c.set(:rails_env, 'production')
19
- c.set(:repository, 'master')
20
- c.set(:deploy_to, '/home/username/app')
21
- c.set(:current_release, '')
22
- c.set(:current_revision, '503ce0923ed177a3ce000005')
17
+ c.set(:rails_env, "production")
18
+ c.set(:repository, "master")
19
+ c.set(:deploy_to, "/home/username/app")
20
+ c.set(:current_release, "")
21
+ c.set(:current_revision, "503ce0923ed177a3ce000005")
23
22
  end
24
23
  end
25
- before { Rake::Task['appsignal:deploy'].reenable }
24
+ before { Rake::Task["appsignal:deploy"].reenable }
26
25
 
27
26
  def run
28
27
  capture_std_streams(out_stream, out_stream) do
29
- invoke('appsignal:deploy')
28
+ capistrano.invoke("appsignal:deploy")
30
29
  end
31
30
  end
32
31
 
33
32
  it "should have a deploy task" do
34
- Rake::Task.task_defined?('appsignal:deploy').should be_true
33
+ Rake::Task.task_defined?("appsignal:deploy").should be_true
35
34
  end
36
35
 
37
36
  describe "appsignal:deploy task" do
38
37
  before do
39
- ENV['USER'] = 'batman'
40
- ENV['PWD'] = project_fixture_path
38
+ ENV["USER"] = "batman"
39
+ ENV["PWD"] = project_fixture_path
41
40
  end
42
41
 
43
42
  context "config" do
44
43
  it "should be instantiated with the right params" do
45
44
  Appsignal::Config.should_receive(:new).with(
46
45
  project_fixture_path,
47
- 'production',
46
+ "production",
48
47
  {},
49
48
  kind_of(Logger)
50
49
  )
@@ -52,14 +51,14 @@ if DependencyHelper.capistrano3_present?
52
51
 
53
52
  context "when appsignal_config is available" do
54
53
  before do
55
- capistrano_config.set(:appsignal_config, :name => 'AppName')
54
+ capistrano_config.set(:appsignal_config, :name => "AppName")
56
55
  end
57
56
 
58
57
  it "should be instantiated with the right params" do
59
58
  Appsignal::Config.should_receive(:new).with(
60
59
  project_fixture_path,
61
- 'production',
62
- {:name => 'AppName'},
60
+ "production",
61
+ { :name => "AppName" },
63
62
  kind_of(Logger)
64
63
  )
65
64
  end
@@ -67,14 +66,14 @@ if DependencyHelper.capistrano3_present?
67
66
  context "when rack_env is the only env set" do
68
67
  before do
69
68
  capistrano_config.delete(:rails_env)
70
- capistrano_config.set(:rack_env, 'rack_production')
69
+ capistrano_config.set(:rack_env, "rack_production")
71
70
  end
72
71
 
73
72
  it "should be instantiated with the rack env" do
74
73
  Appsignal::Config.should_receive(:new).with(
75
74
  project_fixture_path,
76
- 'rack_production',
77
- {:name => 'AppName'},
75
+ "rack_production",
76
+ { :name => "AppName" },
78
77
  kind_of(Logger)
79
78
  )
80
79
  end
@@ -82,15 +81,15 @@ if DependencyHelper.capistrano3_present?
82
81
 
83
82
  context "when stage is set" do
84
83
  before do
85
- capistrano_config.set(:rack_env, 'rack_production')
86
- capistrano_config.set(:stage, 'stage_production')
84
+ capistrano_config.set(:rack_env, "rack_production")
85
+ capistrano_config.set(:stage, "stage_production")
87
86
  end
88
87
 
89
88
  it "should prefer the stage rather than rails_env and rack_env" do
90
89
  Appsignal::Config.should_receive(:new).with(
91
90
  project_fixture_path,
92
- 'stage_production',
93
- {:name => 'AppName'},
91
+ "stage_production",
92
+ { :name => "AppName" },
94
93
  kind_of(Logger)
95
94
  )
96
95
  end
@@ -98,16 +97,16 @@ if DependencyHelper.capistrano3_present?
98
97
 
99
98
  context "when appsignal_env is set" do
100
99
  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')
100
+ capistrano_config.set(:rack_env, "rack_production")
101
+ capistrano_config.set(:stage, "stage_production")
102
+ capistrano_config.set(:appsignal_env, "appsignal_production")
104
103
  end
105
104
 
106
105
  it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
107
106
  Appsignal::Config.should_receive(:new).with(
108
107
  project_fixture_path,
109
- 'appsignal_production',
110
- {:name => 'AppName'},
108
+ "appsignal_production",
109
+ { :name => "AppName" },
111
110
  kind_of(Logger)
112
111
  )
113
112
  end
@@ -119,13 +118,13 @@ if DependencyHelper.capistrano3_present?
119
118
 
120
119
  describe "markers" do
121
120
  def stub_marker_request(data = {})
122
- stub_api_request config, 'markers', marker_data.merge(data)
121
+ stub_api_request config, "markers", marker_data.merge(data)
123
122
  end
124
123
 
125
124
  let(:marker_data) do
126
125
  {
127
- :revision => '503ce0923ed177a3ce000005',
128
- :user => 'batman'
126
+ :revision => "503ce0923ed177a3ce000005",
127
+ :user => "batman"
129
128
  }
130
129
  end
131
130
 
@@ -135,21 +134,21 @@ if DependencyHelper.capistrano3_present?
135
134
  run
136
135
 
137
136
  expect(output).to include \
138
- 'Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
139
- 'AppSignal has been notified of this deploy!'
137
+ "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman",
138
+ "AppSignal has been notified of this deploy!"
140
139
  end
141
140
 
142
141
  context "with overridden revision" do
143
142
  before do
144
- capistrano_config.set(:appsignal_revision, 'abc123')
145
- stub_marker_request(:revision => 'abc123').to_return(:status => 200)
143
+ capistrano_config.set(:appsignal_revision, "abc123")
144
+ stub_marker_request(:revision => "abc123").to_return(:status => 200)
146
145
  run
147
146
  end
148
147
 
149
148
  it "transmits the overriden revision" do
150
149
  expect(output).to include \
151
- 'Notifying AppSignal of deploy with: revision: abc123, user: batman',
152
- 'AppSignal has been notified of this deploy!'
150
+ "Notifying AppSignal of deploy with: revision: abc123, user: batman",
151
+ "AppSignal has been notified of this deploy!"
153
152
  end
154
153
  end
155
154
 
@@ -161,16 +160,16 @@ if DependencyHelper.capistrano3_present?
161
160
 
162
161
  it "does not transmit marker" do
163
162
  expect(output).to include \
164
- 'Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
165
- 'Something went wrong while trying to notify AppSignal:'
166
- expect(output).to_not include 'AppSignal has been notified of this deploy!'
163
+ "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman",
164
+ "Something went wrong while trying to notify AppSignal:"
165
+ expect(output).to_not include "AppSignal has been notified of this deploy!"
167
166
  end
168
167
  end
169
168
  end
170
169
 
171
170
  context "when not active for this environment" do
172
171
  before do
173
- capistrano_config.set(:rails_env, 'nonsense')
172
+ capistrano_config.set(:rails_env, "nonsense")
174
173
  run
175
174
  end
176
175