appsignal 1.3.6 → 1.4.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.rspec +1 -3
  4. data/CHANGELOG.md +2 -28
  5. data/Rakefile +2 -2
  6. data/benchmark.rake +4 -0
  7. data/circle.yml +12 -0
  8. data/ext/agent.yml +11 -11
  9. data/ext/appsignal_extension.c +3 -3
  10. data/ext/extconf.rb +4 -4
  11. data/lib/appsignal.rb +10 -27
  12. data/lib/appsignal/cli/diagnose.rb +3 -4
  13. data/lib/appsignal/cli/install.rb +15 -16
  14. data/lib/appsignal/config.rb +7 -18
  15. data/lib/appsignal/event_formatter.rb +1 -1
  16. data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
  17. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -2
  18. data/lib/appsignal/integrations/object.rb +4 -4
  19. data/lib/appsignal/integrations/sinatra.rb +1 -1
  20. data/lib/appsignal/integrations/webmachine.rb +1 -1
  21. data/lib/appsignal/js_exception_transaction.rb +0 -1
  22. data/lib/appsignal/marker.rb +2 -3
  23. data/lib/appsignal/rack/sinatra_instrumentation.rb +5 -12
  24. data/lib/appsignal/rack/streaming_listener.rb +2 -4
  25. data/lib/appsignal/transaction.rb +3 -3
  26. data/lib/appsignal/transmitter.rb +7 -11
  27. data/lib/appsignal/utils.rb +0 -6
  28. data/lib/appsignal/version.rb +1 -1
  29. data/spec/lib/appsignal/auth_check_spec.rb +2 -0
  30. data/spec/lib/appsignal/capistrano2_spec.rb +78 -98
  31. data/spec/lib/appsignal/capistrano3_spec.rb +77 -56
  32. data/spec/lib/appsignal/cli/diagnose_spec.rb +13 -12
  33. data/spec/lib/appsignal/cli/install_spec.rb +15 -38
  34. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +5 -2
  35. data/spec/lib/appsignal/cli_spec.rb +5 -2
  36. data/spec/lib/appsignal/config_spec.rb +17 -131
  37. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +2 -0
  38. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +2 -0
  39. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +2 -0
  40. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +2 -0
  41. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +2 -0
  42. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +2 -0
  43. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +2 -0
  44. data/spec/lib/appsignal/event_formatter_spec.rb +2 -0
  45. data/spec/lib/appsignal/extension_spec.rb +1 -0
  46. data/spec/lib/appsignal/hooks/celluloid_spec.rb +2 -0
  47. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +2 -0
  48. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +2 -0
  49. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +2 -0
  50. data/spec/lib/appsignal/hooks/net_http_spec.rb +2 -0
  51. data/spec/lib/appsignal/hooks/passenger_spec.rb +2 -0
  52. data/spec/lib/appsignal/hooks/puma_spec.rb +2 -0
  53. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -0
  54. data/spec/lib/appsignal/hooks/redis_spec.rb +2 -0
  55. data/spec/lib/appsignal/hooks/sequel_spec.rb +2 -0
  56. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +4 -1
  57. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +3 -2
  58. data/spec/lib/appsignal/hooks/unicorn_spec.rb +2 -0
  59. data/spec/lib/appsignal/hooks/webmachine_spec.rb +8 -2
  60. data/spec/lib/appsignal/hooks_spec.rb +2 -0
  61. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +1 -0
  62. data/spec/lib/appsignal/integrations/grape_spec.rb +2 -0
  63. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +1 -0
  64. data/spec/lib/appsignal/integrations/object_spec.rb +1 -30
  65. data/spec/lib/appsignal/integrations/padrino_spec.rb +2 -0
  66. data/spec/lib/appsignal/integrations/railtie_spec.rb +2 -0
  67. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +2 -0
  68. data/spec/lib/appsignal/integrations/resque_spec.rb +3 -1
  69. data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -32
  70. data/spec/lib/appsignal/integrations/webmachine_spec.rb +11 -4
  71. data/spec/lib/appsignal/js_exception_transaction_spec.rb +2 -0
  72. data/spec/lib/appsignal/marker_spec.rb +48 -35
  73. data/spec/lib/appsignal/minutely_spec.rb +2 -0
  74. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -0
  75. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +2 -0
  76. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +2 -0
  77. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +6 -46
  78. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +4 -3
  79. data/spec/lib/appsignal/subscriber_spec.rb +2 -0
  80. data/spec/lib/appsignal/transaction_spec.rb +3 -2
  81. data/spec/lib/appsignal/transmitter_spec.rb +20 -53
  82. data/spec/lib/appsignal/update_active_support_spec.rb +2 -0
  83. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +2 -0
  84. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +2 -0
  85. data/spec/lib/appsignal/utils_spec.rb +2 -0
  86. data/spec/lib/appsignal_spec.rb +37 -91
  87. data/spec/spec_helper.rb +28 -22
  88. metadata +5 -14
  89. data/spec/lib/appsignal/utils/gzip_spec.rb +0 -10
  90. data/spec/support/helpers/api_request_helper.rb +0 -19
  91. data/spec/support/helpers/directory_helper.rb +0 -25
  92. data/spec/support/helpers/std_streams_helper.rb +0 -35
  93. data/spec/support/helpers/very_specific_error.rb +0 -8
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  if capistrano3_present?
2
4
  require 'capistrano/all'
3
5
  require 'capistrano/deploy'
@@ -9,23 +11,22 @@ if capistrano3_present?
9
11
  let(:config) { project_fixture_config }
10
12
  let(:out_stream) { StringIO.new }
11
13
  let(:logger) { Logger.new(out_stream) }
12
- let!(:capistrano_config) do
13
- Capistrano::Configuration.reset!
14
- Capistrano::Configuration.env.tap do |c|
15
- c.set(:log_level, :error)
16
- c.set(:logger, logger)
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')
22
- end
14
+
15
+ before do
16
+ @capistrano_config = Capistrano::Configuration.env
17
+ @capistrano_config.set(:log_level, :error)
18
+ @capistrano_config.set(:logger, logger)
23
19
  end
24
20
  before do
25
- Rake::Task['appsignal:deploy'].reenable
21
+ @original_stdout = $stdout
22
+ $stdout = out_stream
23
+ @original_stderr = $stderr
24
+ $stderr = out_stream
26
25
  end
27
- around do |example|
28
- capture_std_streams(out_stream, out_stream) { example.run }
26
+ after do
27
+ $stdout = @original_stdout
28
+ $stderr = @original_stderr
29
+ Rake::Task['appsignal:deploy'].reenable
29
30
  end
30
31
 
31
32
  it "should have a deploy task" do
@@ -34,6 +35,11 @@ if capistrano3_present?
34
35
 
35
36
  describe "appsignal:deploy task" do
36
37
  before do
38
+ @capistrano_config.set(:rails_env, 'production')
39
+ @capistrano_config.set(:repository, 'master')
40
+ @capistrano_config.set(:deploy_to, '/home/username/app')
41
+ @capistrano_config.set(:current_release, '')
42
+ @capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
37
43
  ENV['USER'] = 'batman'
38
44
  ENV['PWD'] = project_fixture_path
39
45
  end
@@ -50,7 +56,7 @@ if capistrano3_present?
50
56
 
51
57
  context "when appsignal_config is available" do
52
58
  before do
53
- capistrano_config.set(:appsignal_config, :name => 'AppName')
59
+ @capistrano_config.set(:appsignal_config, :name => 'AppName')
54
60
  end
55
61
 
56
62
  it "should be instantiated with the right params" do
@@ -64,8 +70,8 @@ if capistrano3_present?
64
70
 
65
71
  context "when rack_env is the only env set" do
66
72
  before do
67
- capistrano_config.delete(:rails_env)
68
- capistrano_config.set(:rack_env, 'rack_production')
73
+ @capistrano_config.delete(:rails_env)
74
+ @capistrano_config.set(:rack_env, 'rack_production')
69
75
  end
70
76
 
71
77
  it "should be instantiated with the rack env" do
@@ -80,8 +86,8 @@ if capistrano3_present?
80
86
 
81
87
  context "when stage is set" do
82
88
  before do
83
- capistrano_config.set(:rack_env, 'rack_production')
84
- capistrano_config.set(:stage, 'stage_production')
89
+ @capistrano_config.set(:rack_env, 'rack_production')
90
+ @capistrano_config.set(:stage, 'stage_production')
85
91
  end
86
92
 
87
93
  it "should prefer the stage rather than rails_env and rack_env" do
@@ -96,9 +102,9 @@ if capistrano3_present?
96
102
 
97
103
  context "when appsignal_env is set" do
98
104
  before do
99
- capistrano_config.set(:rack_env, 'rack_production')
100
- capistrano_config.set(:stage, 'stage_production')
101
- capistrano_config.set(:appsignal_env, 'appsignal_production')
105
+ @capistrano_config.set(:rack_env, 'rack_production')
106
+ @capistrano_config.set(:stage, 'stage_production')
107
+ @capistrano_config.set(:appsignal_env, 'appsignal_production')
102
108
  end
103
109
 
104
110
  it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
@@ -114,14 +120,13 @@ if capistrano3_present?
114
120
 
115
121
  after do
116
122
  invoke('appsignal:deploy')
123
+ @capistrano_config.delete(:stage)
124
+ @capistrano_config.delete(:rack_env)
125
+ @capistrano_config.delete(:appsignal_env)
117
126
  end
118
127
  end
119
128
 
120
- describe "markers" do
121
- def stub_marker_request(data = {})
122
- stub_api_request config, 'markers', marker_data.merge(data)
123
- end
124
-
129
+ context "send marker" do
125
130
  let(:marker_data) do
126
131
  {
127
132
  :revision => '503ce0923ed177a3ce000005',
@@ -130,54 +135,70 @@ if capistrano3_present?
130
135
  end
131
136
 
132
137
  context "when active for this environment" do
133
- it "transmits marker" do
134
- stub_marker_request.to_return(:status => 200)
135
- invoke('appsignal:deploy')
136
-
137
- expect(out_stream.string).to include \
138
- 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
139
- 'Appsignal has been notified of this deploy!'
138
+ before do
139
+ @marker = Appsignal::Marker.new(
140
+ marker_data,
141
+ config
142
+ )
143
+ Appsignal::Marker.stub(:new => @marker)
140
144
  end
141
145
 
142
- context "with overridden revision" do
146
+ context "proper setup" do
143
147
  before do
144
- capistrano_config.set(:appsignal_revision, 'abc123')
145
- stub_marker_request(:revision => 'abc123').to_return(:status => 200)
146
- invoke('appsignal:deploy')
148
+ @transmitter = double
149
+ Appsignal::Transmitter.should_receive(:new).and_return(@transmitter)
147
150
  end
148
151
 
149
- it "transmits the overriden revision" do
150
- expect(out_stream.string).to include \
151
- 'Notifying Appsignal of deploy with: revision: abc123, user: batman',
152
- 'Appsignal has been notified of this deploy!'
152
+ it "should add the correct marker data" do
153
+ Appsignal::Marker.should_receive(:new).with(
154
+ marker_data,
155
+ kind_of(Appsignal::Config)
156
+ ).and_return(@marker)
157
+
158
+ invoke('appsignal:deploy')
153
159
  end
154
- end
155
160
 
156
- context "with failed request" do
157
- before do
158
- stub_marker_request.to_return(:status => 500)
161
+ it "should transmit data" do
162
+ @transmitter.should_receive(:transmit).and_return('200')
159
163
  invoke('appsignal:deploy')
164
+ out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
165
+ out_stream.string.should include('ppsignal has been notified of this deploy!')
160
166
  end
161
167
 
162
- it "does not transmit marker" do
163
- output = out_stream.string
164
- expect(output).to include \
165
- 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
166
- 'Something went wrong while trying to notify Appsignal:'
167
- expect(output).to_not include 'Appsignal has been notified of this deploy!'
168
+ context "with overridden revision" do
169
+ before do
170
+ @capistrano_config.set(:appsignal_revision, 'abc123')
171
+ end
172
+ it "should add the correct marker data" do
173
+ Appsignal::Marker.should_receive(:new).with(
174
+ {
175
+ :revision => 'abc123',
176
+ :user => 'batman'
177
+ },
178
+ kind_of(Appsignal::Config)
179
+ ).and_return(@marker)
180
+
181
+ invoke('appsignal:deploy')
182
+ end
168
183
  end
169
184
  end
185
+
186
+ it "should not transmit data" do
187
+ invoke('appsignal:deploy')
188
+ out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
189
+ out_stream.string.should include('Something went wrong while trying to notify Appsignal:')
190
+ end
170
191
  end
171
192
 
172
193
  context "when not active for this environment" do
173
194
  before do
174
- capistrano_config.set(:rails_env, 'nonsense')
175
- invoke('appsignal:deploy')
195
+ @capistrano_config.set(:rails_env, 'nonsense')
176
196
  end
177
197
 
178
198
  it "should not send deploy marker" do
179
- expect(out_stream.string).to include \
180
- "Not notifying of deploy, config is not active for environment: nonsense"
199
+ Appsignal::Marker.should_not_receive(:new)
200
+ invoke('appsignal:deploy')
201
+ out_stream.string.should include("Not notifying of deploy, config is not active")
181
202
  end
182
203
  end
183
204
  end
@@ -1,26 +1,27 @@
1
+ require 'spec_helper'
1
2
  require 'appsignal/cli'
2
3
 
3
4
  describe Appsignal::CLI::Diagnose do
4
5
  let(:out_stream) { StringIO.new }
5
6
  let(:cli) { Appsignal::CLI::Diagnose }
6
- around do |example|
7
- original_stdout = $stdout
7
+ before do
8
+ @original_stdout = $stdout
8
9
  $stdout = out_stream
9
- example.run
10
- $stdout = original_stdout
10
+ end
11
+ after do
12
+ $stdout = @original_stdout
11
13
  end
12
14
 
13
15
  describe ".run" do
14
16
  it "should output diagnostic information" do
15
17
  cli.run
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')
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')
24
25
  end
25
26
  end
26
27
  end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'appsignal/cli'
2
3
 
3
4
  begin
@@ -13,13 +14,15 @@ describe Appsignal::CLI::Install do
13
14
 
14
15
  before do
15
16
  Dir.stub(:pwd => project_fixture_path)
17
+ @original_stdout = $stdout
18
+ $stdout = out_stream
16
19
  Appsignal::AuthCheck.stub(:new => auth_check)
17
20
  auth_check.stub(:perform => '200')
18
21
  cli.stub(:sleep)
19
22
  cli.stub(:press_any_key)
20
23
  end
21
- around do |example|
22
- capture_stdout(out_stream) { example.run }
24
+ after do
25
+ $stdout = @original_stdout
23
26
  end
24
27
 
25
28
  describe ".run" do
@@ -372,50 +375,24 @@ describe Appsignal::CLI::Install do
372
375
  end
373
376
  end
374
377
 
375
- context "with capistrano" do
376
- let(:capfile) { File.join(tmp_dir, 'Capfile') }
378
+ context "when deploy.rb is present" do
379
+ let(:config_dir) { File.join(tmp_dir, 'config') }
380
+ let(:deploy_rb_file) { File.join(tmp_dir, 'config/deploy.rb') }
377
381
  before do
378
382
  Dir.stub(:pwd => tmp_dir)
379
- FileUtils.mkdir_p(tmp_dir)
383
+ FileUtils.mkdir_p(config_dir)
384
+ FileUtils.touch(deploy_rb_file)
380
385
  cli.should_receive(:gets).once.and_return('2')
381
386
  end
382
387
  after do
383
- FileUtils.rm_rf(tmp_dir)
388
+ FileUtils.rm_rf(config_dir)
384
389
  end
385
390
 
386
- context "without Capfile" do
387
- before { cli.configure(config, [], false) }
388
-
389
- it "does nothing" do
390
- expect(out_stream.string).to_not include 'Adding AppSignal integration to Capfile'
391
- expect(File.exist?(capfile)).to be_false
392
- end
393
- end
394
-
395
- context "with Capfile" do
396
- context "when already installed" do
397
- before do
398
- File.open(capfile, 'w') { |f| f.write("require 'appsignal/capistrano'") }
399
- cli.configure(config, [], false)
400
- end
401
-
402
- it "does not add another require to Capfile" do
403
- expect(out_stream.string).to_not include 'Adding AppSignal integration to Capfile'
404
- expect(File.read(capfile).scan(/appsignal/).count).to eq(1)
405
- end
406
- end
407
-
408
- context "when not installed" do
409
- before do
410
- FileUtils.touch(capfile)
411
- cli.configure(config, [], false)
412
- end
391
+ it "should add a require to deploy.rb" do
392
+ cli.configure(config, [], false)
413
393
 
414
- it "adds a require to Capfile" do
415
- expect(out_stream.string).to include 'Adding AppSignal integration to Capfile'
416
- expect(File.read(capfile)).to include "require 'appsignal/capistrano'"
417
- end
418
- end
394
+ out_stream.string.should include 'Adding AppSignal integration to deploy.rb'
395
+ File.read(deploy_rb_file).should include "require 'appsignal/capistrano'"
419
396
  end
420
397
  end
421
398
  end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'appsignal/cli'
2
3
 
3
4
  describe Appsignal::CLI::NotifyOfDeploy do
@@ -6,10 +7,12 @@ describe Appsignal::CLI::NotifyOfDeploy do
6
7
  let(:config) { Appsignal::Config.new(project_fixture_path, {}) }
7
8
  let(:marker_data) { {:revision => 'aaaaa', :user => 'thijs', :environment => 'production'} }
8
9
  before do
10
+ @original_stdout = $stdout
11
+ $stdout = out_stream
9
12
  config.stub(:active? => true)
10
13
  end
11
- around do |example|
12
- capture_stdout(out_stream) { example.run }
14
+ after do
15
+ $stdout = @original_stdout
13
16
  end
14
17
 
15
18
  describe ".run" do
@@ -1,14 +1,17 @@
1
+ require 'spec_helper'
1
2
  require 'appsignal/cli'
2
3
 
3
4
  describe Appsignal::CLI do
4
5
  let(:out_stream) { StringIO.new }
5
6
  let(:cli) { Appsignal::CLI }
6
7
  before do
8
+ @original_stdout = $stdout
9
+ $stdout = out_stream
7
10
  Dir.stub(:pwd => project_fixture_path)
8
11
  cli.options = {:environment => 'production'}
9
12
  end
10
- around do |example|
11
- capture_stdout(out_stream) { example.run }
13
+ after do
14
+ $stdout = @original_stdout
12
15
  end
13
16
 
14
17
  describe "#config" do
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe Appsignal::Config do
2
4
  subject { config }
3
5
 
@@ -35,150 +37,35 @@ describe Appsignal::Config do
35
37
  :running_in_container => false,
36
38
  :enable_host_metrics => true,
37
39
  :enable_minutely_probes => false,
38
- :hostname => Socket.gethostname,
39
- :ca_file_path => File.join(resources_dir, 'cacert.pem')
40
+ :hostname => Socket.gethostname
40
41
  })
41
42
  end
42
43
 
43
- describe "#log_file_path" do
44
- let(:stdout) { StringIO.new }
45
- let(:config) { project_fixture_config('production', :log_path => log_path) }
46
- subject { config.log_file_path }
47
- around do |example|
48
- original_stdout = $stdout
49
- $stdout = stdout
50
- example.run
51
- $stdout = original_stdout
52
- end
53
-
54
- context "when path is writable" do
55
- let(:log_path) { File.join(tmp_dir, 'writable-path') }
56
- before { FileUtils.mkdir_p(log_path, :mode => 0755) }
57
- after { FileUtils.rm_rf(log_path) }
58
-
59
- it "returns log file path" do
60
- expect(subject).to eq File.join(log_path, 'appsignal.log')
61
- end
62
-
63
- it "prints no warning" do
64
- subject
65
- expect(stdout.string).to be_empty
66
- end
67
- end
68
-
69
- shared_examples '#log_file_path: tmp path' do
70
- let(:system_tmp_dir) { Appsignal::Config::SYSTEM_TMP_DIR }
71
- before { FileUtils.mkdir_p(system_tmp_dir) }
72
- after { FileUtils.rm_rf(system_tmp_dir) }
73
-
74
- context "when the /tmp fallback path is writable" do
75
- before { FileUtils.chmod(0777, system_tmp_dir) }
76
-
77
- it "returns returns the tmp location" do
78
- expect(subject).to eq(File.join(system_tmp_dir, 'appsignal.log'))
79
- end
80
-
81
- it "prints a warning" do
82
- subject
83
- expect(stdout.string).to include "appsignal: Unable to log to '#{log_path}'. "\
84
- "Logging to '#{system_tmp_dir}' instead."
85
- end
86
- end
87
-
88
- context "when the /tmp fallback path is not writable" do
89
- before { FileUtils.chmod(0555, system_tmp_dir) }
90
-
91
- it "returns nil" do
92
- expect(subject).to be_nil
93
- end
44
+ context "if a log file path is set" do
45
+ let(:config) { project_fixture_config('production', :log_path => '/tmp') }
94
46
 
95
- it "prints a warning" do
96
- subject
97
- expect(stdout.string).to include "appsignal: Unable to log to '#{log_path}' "\
98
- "or the '#{system_tmp_dir}' fallback."
99
- end
100
- end
101
- end
47
+ its(:log_file_path) { should end_with('/tmp/appsignal.log') }
102
48
 
103
- context "when path is nil" do
104
- let(:log_path) { nil }
105
-
106
- context "when root_path is nil" do
107
- before { allow(config).to receive(:root_path).and_return(nil) }
108
-
109
- include_examples '#log_file_path: tmp path'
110
- end
49
+ context "if it is not writable" do
50
+ before { FileUtils.mkdir_p('/tmp/not-writable', :mode => 0555) }
111
51
 
112
- context "when root_path is set" do
113
- it "returns returns the project log location" do
114
- expect(subject).to eq File.join(config.root_path, 'appsignal.log')
115
- end
52
+ let(:config) { project_fixture_config('production', :log_path => '/tmp/not-writable') }
116
53
 
117
- it "prints no warning" do
118
- subject
119
- expect(stdout.string).to be_empty
120
- end
121
- end
122
- end
123
-
124
- context "when path does not exist" do
125
- let(:log_path) { '/non-existing' }
126
-
127
- include_examples '#log_file_path: tmp path'
54
+ its(:log_file_path) { should eq '/tmp/appsignal.log' }
128
55
  end
129
56
 
130
- context "when path is not writable" do
131
- let(:log_path) { File.join(tmp_dir, 'not-writable-path') }
132
- before { FileUtils.mkdir_p(log_path, :mode => 0555) }
133
- after { FileUtils.rm_rf(log_path) }
57
+ context "if it does not exist" do
58
+ let(:config) { project_fixture_config('production', :log_path => '/non-existing') }
134
59
 
135
- include_examples '#log_file_path: tmp path'
60
+ its(:log_file_path) { should eq '/tmp/appsignal.log' }
136
61
  end
137
62
 
138
- context "when path is a symlink" do
139
- context "when linked path does not exist" do
140
- let(:real_path) { File.join(tmp_dir, 'real-path') }
141
- let(:log_path) { File.join(tmp_dir, 'symlink-path') }
142
- before { File.symlink(real_path, log_path) }
143
- after { FileUtils.rm(log_path) }
63
+ context "if it is nil" do
64
+ let(:config) { project_fixture_config('production', :log_path => nil) }
144
65
 
145
- include_examples '#log_file_path: tmp path'
146
- end
66
+ before { config.stub(:root_path => nil) }
147
67
 
148
- context "when linked path exists" do
149
- context "when linked path is not writable" do
150
- let(:real_path) { File.join(tmp_dir, 'real-path') }
151
- let(:log_path) { File.join(tmp_dir, 'symlink-path') }
152
- before do
153
- FileUtils.mkdir_p(real_path)
154
- FileUtils.chmod(0444, real_path)
155
- File.symlink(real_path, log_path)
156
- end
157
- after do
158
- FileUtils.rm_rf(real_path)
159
- FileUtils.rm(log_path)
160
- end
161
-
162
- include_examples '#log_file_path: tmp path'
163
- end
164
-
165
- context "when linked path is writable" do
166
- let(:real_path) { File.join(tmp_dir, 'real-path') }
167
- let(:log_path) { File.join(tmp_dir, 'symlink-path') }
168
- before do
169
- FileUtils.mkdir_p(real_path)
170
- File.symlink(real_path, log_path)
171
- end
172
- after do
173
- FileUtils.rm_rf(real_path)
174
- FileUtils.rm(log_path)
175
- end
176
-
177
- it "returns real path of log path" do
178
- expect(subject).to eq(File.join(real_path, 'appsignal.log'))
179
- end
180
- end
181
- end
68
+ its(:log_file_path) { should eq '/tmp/appsignal.log' }
182
69
  end
183
70
  end
184
71
 
@@ -245,7 +132,6 @@ describe Appsignal::Config do
245
132
  ENV['APPSIGNAL_ENABLE_MINUTELY_PROBES'].should eq 'false'
246
133
  ENV['APPSIGNAL_HOSTNAME'].should eq 'app1.local'
247
134
  ENV['APPSIGNAL_PROCESS_NAME'].should include 'rspec'
248
- ENV['APPSIGNAL_CA_FILE_PATH'].should eq File.join(resources_dir, "cacert.pem")
249
135
  end
250
136
 
251
137
  context "if working_dir_path is set" do