appsignal 1.3.6.beta.1 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c006b3a5ff128b594596cc197d2f9c1b7a2c6a8e
4
- data.tar.gz: caf8636d1ba933831cf582f65962d2c7155b62a9
3
+ metadata.gz: 66a5631dc247e540f18fdb0d2e212d3c8125fd95
4
+ data.tar.gz: b6aad615e011a4bdd7392f5ea9d0c528f0432d2b
5
5
  SHA512:
6
- metadata.gz: ddcb3f8151c062c01a029a595a7ca0d93cd93920bdeb1cf8cbc4f0922ab66fc291fba56fc3db3f2f121779a4bd3a186959da19ac1105a56fa251c6963e1c95ae
7
- data.tar.gz: 5c79420049ae3cf242c426e1953c7a3286fa4630dd018703534b30502a2ec33aeb085ba5339e6caed01430c5629050eb571ffb9d533d69f483f4e6871fabebf5
6
+ metadata.gz: 658ef073b6ba0ed43d3cef4f1ea110a22cdbf048985e514f3f0111b7d084df8dccfe6272f95cb5ca4aa1e976f9f8c60788157ee2796dcb5416ec4aaef8a21a70
7
+ data.tar.gz: abf3ae40acc98613930b7b05d1b42a130defcca4e1fdcb2e4a1a9b6e871d4f92de625d54a0b65de9a957edbca6bce396c6b605045ac6fe9d32f93f5da1eba832
@@ -34,6 +34,7 @@ module Appsignal
34
34
  def set_sample_data
35
35
  {
36
36
  :params => @data['params'],
37
+ :session_data => @data['session_data'],
37
38
  :environment => @data['environment'],
38
39
  :tags => @data['tags']
39
40
  }.each do |key, data|
@@ -10,14 +10,15 @@ module Appsignal
10
10
 
11
11
  def transmit
12
12
  transmitter = Transmitter.new(ACTION, config)
13
- puts "Notifying Appsignal of deploy with: revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"
13
+ puts "Notifying Appsignal of deploy with: "\
14
+ "revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"
14
15
  result = transmitter.transmit(marker_data)
15
16
  if result == '200'
16
17
  puts 'Appsignal has been notified of this deploy!'
17
18
  else
18
19
  raise "#{result} at #{transmitter.uri}"
19
20
  end
20
- rescue Exception => e
21
+ rescue => e
21
22
  puts "Something went wrong while trying to notify Appsignal: #{e}"
22
23
  end
23
24
  end
@@ -51,10 +51,8 @@ module Appsignal
51
51
  Net::HTTP::Post.new(uri.request_uri).tap do |request|
52
52
  request['Content-Type'] = CONTENT_TYPE
53
53
  request['Content-Encoding'] = CONTENT_ENCODING
54
- request.body = Zlib::Deflate.deflate(
55
- Appsignal::Utils.json_generate(payload),
56
- Zlib::BEST_SPEED
57
- )
54
+ request.body = Appsignal::Utils::Gzip.compress \
55
+ Appsignal::Utils::JSON.generate(payload)
58
56
  end
59
57
  end
60
58
 
@@ -52,5 +52,11 @@ module Appsignal
52
52
 
53
53
  extend ClassMethods
54
54
  end
55
+
56
+ class Gzip
57
+ def self.compress(body)
58
+ Zlib::Deflate.deflate(body, Zlib::BEST_SPEED)
59
+ end
60
+ end
55
61
  end
56
62
  end
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Appsignal
4
- VERSION = '1.3.6.beta.1'
4
+ VERSION = '1.3.6'
5
5
  end
@@ -6,33 +6,36 @@ if capistrano2_present?
6
6
  describe "Capistrano 2 integration" do
7
7
  let(:out_stream) { StringIO.new }
8
8
  let(:config) { project_fixture_config }
9
- before :all do
10
- @capistrano_config = Capistrano::Configuration.new
11
- Appsignal::Capistrano.tasks(@capistrano_config)
9
+ let(:capistrano_config) do
10
+ Capistrano::Configuration.new.tap do |c|
11
+ c.set(:rails_env, 'production')
12
+ c.set(:repository, 'master')
13
+ c.set(:deploy_to, '/home/username/app')
14
+ c.set(:current_release, '')
15
+ c.set(:current_revision, '503ce0923ed177a3ce000005')
16
+ c.dry_run = false
17
+ end
18
+ end
19
+ before do
20
+ Appsignal::Capistrano.tasks(capistrano_config)
12
21
  end
13
22
  around do |example|
14
23
  capture_stdout(out_stream) { example.run }
15
24
  end
16
25
 
17
26
  it "should have a deploy task" do
18
- @capistrano_config.find_task('appsignal:deploy').should_not be_nil
27
+ capistrano_config.find_task('appsignal:deploy').should_not be_nil
19
28
  end
20
29
 
21
30
  describe "appsignal:deploy task" do
22
31
  before do
23
- @capistrano_config.set(:rails_env, 'production')
24
- @capistrano_config.set(:repository, 'master')
25
- @capistrano_config.set(:deploy_to, '/home/username/app')
26
- @capistrano_config.set(:current_release, '')
27
- @capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
28
- @capistrano_config.dry_run = false
29
32
  ENV['USER'] = 'batman'
30
33
  ENV['PWD'] = project_fixture_path
31
34
  end
32
35
 
33
36
  context "config" do
34
37
  before do
35
- @capistrano_config.dry_run = true
38
+ capistrano_config.dry_run = true
36
39
  end
37
40
 
38
41
  it "should be instantiated with the right params" do
@@ -46,7 +49,7 @@ if capistrano2_present?
46
49
 
47
50
  context "when appsignal_config is available" do
48
51
  before do
49
- @capistrano_config.set(:appsignal_config, :name => 'AppName')
52
+ capistrano_config.set(:appsignal_config, :name => 'AppName')
50
53
  end
51
54
 
52
55
  it "should be instantiated with the right params" do
@@ -60,8 +63,8 @@ if capistrano2_present?
60
63
 
61
64
  context "when rack_env is used instead of rails_env" do
62
65
  before do
63
- @capistrano_config.unset(:rails_env)
64
- @capistrano_config.set(:rack_env, 'rack_production')
66
+ capistrano_config.unset(:rails_env)
67
+ capistrano_config.set(:rack_env, 'rack_production')
65
68
  end
66
69
 
67
70
  it "should be instantiated with the right params" do
@@ -76,8 +79,8 @@ if capistrano2_present?
76
79
 
77
80
  context "when stage is used instead of rack_env / rails_env" do
78
81
  before do
79
- @capistrano_config.unset(:rails_env)
80
- @capistrano_config.set(:stage, 'stage_production')
82
+ capistrano_config.unset(:rails_env)
83
+ capistrano_config.set(:stage, 'stage_production')
81
84
  end
82
85
 
83
86
  it "should be instantiated with the right params" do
@@ -92,9 +95,9 @@ if capistrano2_present?
92
95
 
93
96
  context "when appsignal_env is set" do
94
97
  before do
95
- @capistrano_config.set(:rack_env, 'rack_production')
96
- @capistrano_config.set(:stage, 'stage_production')
97
- @capistrano_config.set(:appsignal_env, 'appsignal_production')
98
+ capistrano_config.set(:rack_env, 'rack_production')
99
+ capistrano_config.set(:stage, 'stage_production')
100
+ capistrano_config.set(:appsignal_env, 'appsignal_production')
98
101
  end
99
102
 
100
103
  it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
@@ -109,14 +112,15 @@ if capistrano2_present?
109
112
  end
110
113
 
111
114
  after do
112
- @capistrano_config.find_and_execute_task('appsignal:deploy')
113
- @capistrano_config.unset(:stage)
114
- @capistrano_config.unset(:rack_env)
115
- @capistrano_config.unset(:appsignal_env)
115
+ capistrano_config.find_and_execute_task('appsignal:deploy')
116
116
  end
117
117
  end
118
118
 
119
- context "send marker" do
119
+ describe "markers" do
120
+ def stub_marker_request(data = {})
121
+ stub_api_request config, 'markers', marker_data.merge(data)
122
+ end
123
+
120
124
  let(:marker_data) do
121
125
  {
122
126
  :revision => '503ce0923ed177a3ce000005',
@@ -125,80 +129,66 @@ if capistrano2_present?
125
129
  end
126
130
 
127
131
  context "when active for this environment" do
128
- before do
129
- @marker = Appsignal::Marker.new(
130
- marker_data,
131
- config
132
- )
133
- Appsignal::Marker.stub(:new => @marker)
132
+ it "transmits marker" do
133
+ stub_marker_request.to_return(:status => 200)
134
+ capistrano_config.find_and_execute_task('appsignal:deploy')
135
+
136
+ expect(out_stream.string).to include \
137
+ 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
138
+ 'Appsignal has been notified of this deploy!'
134
139
  end
135
140
 
136
- context "proper setup" do
141
+ context "with overridden revision" do
137
142
  before do
138
- @transmitter = double
139
- Appsignal::Transmitter.should_receive(:new).and_return(@transmitter)
143
+ capistrano_config.set(:appsignal_revision, 'abc123')
144
+ stub_marker_request(:revision => 'abc123').to_return(:status => 200)
145
+ capistrano_config.find_and_execute_task('appsignal:deploy')
140
146
  end
141
147
 
142
- it "should add the correct marker data" do
143
- Appsignal::Marker.should_receive(:new).with(
144
- marker_data,
145
- kind_of(Appsignal::Config)
146
- ).and_return(@marker)
147
-
148
- @capistrano_config.find_and_execute_task('appsignal:deploy')
148
+ it "transmits the overriden revision" do
149
+ expect(out_stream.string).to include \
150
+ 'Notifying Appsignal of deploy with: revision: abc123, user: batman',
151
+ 'Appsignal has been notified of this deploy!'
149
152
  end
153
+ end
150
154
 
151
- it "should transmit data" do
152
- @transmitter.should_receive(:transmit).and_return('200')
153
- @capistrano_config.find_and_execute_task('appsignal:deploy')
154
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
155
- out_stream.string.should include('Appsignal has been notified of this deploy!')
155
+ context "with failed request" do
156
+ before do
157
+ stub_marker_request.to_return(:status => 500)
158
+ capistrano_config.find_and_execute_task('appsignal:deploy')
156
159
  end
157
160
 
158
- context "with overridden revision" do
159
- before do
160
- @capistrano_config.set(:appsignal_revision, 'abc123')
161
- end
162
- it "should add the correct marker data" do
163
- Appsignal::Marker.should_receive(:new).with(
164
- {
165
- :revision => 'abc123',
166
- :user => 'batman'
167
- },
168
- kind_of(Appsignal::Config)
169
- ).and_return(@marker)
170
-
171
- @capistrano_config.find_and_execute_task('appsignal:deploy')
172
- end
161
+ it "does not transmit marker" do
162
+ output = out_stream.string
163
+ 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!'
173
167
  end
174
168
  end
175
169
 
176
- it "should not transmit data" do
177
- @capistrano_config.find_and_execute_task('appsignal:deploy')
178
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
179
- out_stream.string.should include('Something went wrong while trying to notify Appsignal:')
180
- end
181
-
182
- context "dry run" do
183
- before { @capistrano_config.dry_run = true }
170
+ context "when dry run" do
171
+ before do
172
+ capistrano_config.dry_run = true
173
+ capistrano_config.find_and_execute_task('appsignal:deploy')
174
+ end
184
175
 
185
- it "should not send deploy marker" do
186
- @marker.should_not_receive(:transmit)
187
- @capistrano_config.find_and_execute_task('appsignal:deploy')
188
- out_stream.string.should include('Dry run: AppSignal deploy marker not actually sent.')
176
+ it "does not transmit marker" do
177
+ expect(out_stream.string).to include \
178
+ 'Dry run: AppSignal deploy marker not actually sent.'
189
179
  end
190
180
  end
191
181
  end
192
182
 
193
183
  context "when not active for this environment" do
194
184
  before do
195
- @capistrano_config.set(:rails_env, 'nonsense')
185
+ capistrano_config.set(:rails_env, 'nonsense')
186
+ capistrano_config.find_and_execute_task('appsignal:deploy')
196
187
  end
197
188
 
198
- it "should not send deploy marker" do
199
- Appsignal::Marker.should_not_receive(:new)
200
- @capistrano_config.find_and_execute_task('appsignal:deploy')
201
- out_stream.string.should include('Not notifying of deploy, config is not active for environment: nonsense')
189
+ it "does not transmit marker" do
190
+ expect(out_stream.string).to include \
191
+ "Not notifying of deploy, config is not active for environment: nonsense"
202
192
  end
203
193
  end
204
194
  end
@@ -9,11 +9,19 @@ if capistrano3_present?
9
9
  let(:config) { project_fixture_config }
10
10
  let(:out_stream) { StringIO.new }
11
11
  let(:logger) { Logger.new(out_stream) }
12
-
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
23
+ end
13
24
  before do
14
- @capistrano_config = Capistrano::Configuration.env
15
- @capistrano_config.set(:log_level, :error)
16
- @capistrano_config.set(:logger, logger)
17
25
  Rake::Task['appsignal:deploy'].reenable
18
26
  end
19
27
  around do |example|
@@ -26,11 +34,6 @@ if capistrano3_present?
26
34
 
27
35
  describe "appsignal:deploy task" do
28
36
  before do
29
- @capistrano_config.set(:rails_env, 'production')
30
- @capistrano_config.set(:repository, 'master')
31
- @capistrano_config.set(:deploy_to, '/home/username/app')
32
- @capistrano_config.set(:current_release, '')
33
- @capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
34
37
  ENV['USER'] = 'batman'
35
38
  ENV['PWD'] = project_fixture_path
36
39
  end
@@ -47,7 +50,7 @@ if capistrano3_present?
47
50
 
48
51
  context "when appsignal_config is available" do
49
52
  before do
50
- @capistrano_config.set(:appsignal_config, :name => 'AppName')
53
+ capistrano_config.set(:appsignal_config, :name => 'AppName')
51
54
  end
52
55
 
53
56
  it "should be instantiated with the right params" do
@@ -61,8 +64,8 @@ if capistrano3_present?
61
64
 
62
65
  context "when rack_env is the only env set" do
63
66
  before do
64
- @capistrano_config.delete(:rails_env)
65
- @capistrano_config.set(:rack_env, 'rack_production')
67
+ capistrano_config.delete(:rails_env)
68
+ capistrano_config.set(:rack_env, 'rack_production')
66
69
  end
67
70
 
68
71
  it "should be instantiated with the rack env" do
@@ -77,8 +80,8 @@ if capistrano3_present?
77
80
 
78
81
  context "when stage is set" do
79
82
  before do
80
- @capistrano_config.set(:rack_env, 'rack_production')
81
- @capistrano_config.set(:stage, 'stage_production')
83
+ capistrano_config.set(:rack_env, 'rack_production')
84
+ capistrano_config.set(:stage, 'stage_production')
82
85
  end
83
86
 
84
87
  it "should prefer the stage rather than rails_env and rack_env" do
@@ -93,9 +96,9 @@ if capistrano3_present?
93
96
 
94
97
  context "when appsignal_env is set" do
95
98
  before do
96
- @capistrano_config.set(:rack_env, 'rack_production')
97
- @capistrano_config.set(:stage, 'stage_production')
98
- @capistrano_config.set(:appsignal_env, 'appsignal_production')
99
+ capistrano_config.set(:rack_env, 'rack_production')
100
+ capistrano_config.set(:stage, 'stage_production')
101
+ capistrano_config.set(:appsignal_env, 'appsignal_production')
99
102
  end
100
103
 
101
104
  it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
@@ -111,13 +114,14 @@ if capistrano3_present?
111
114
 
112
115
  after do
113
116
  invoke('appsignal:deploy')
114
- @capistrano_config.delete(:stage)
115
- @capistrano_config.delete(:rack_env)
116
- @capistrano_config.delete(:appsignal_env)
117
117
  end
118
118
  end
119
119
 
120
- context "send marker" do
120
+ describe "markers" do
121
+ def stub_marker_request(data = {})
122
+ stub_api_request config, 'markers', marker_data.merge(data)
123
+ end
124
+
121
125
  let(:marker_data) do
122
126
  {
123
127
  :revision => '503ce0923ed177a3ce000005',
@@ -126,70 +130,54 @@ if capistrano3_present?
126
130
  end
127
131
 
128
132
  context "when active for this environment" do
129
- before do
130
- @marker = Appsignal::Marker.new(
131
- marker_data,
132
- config
133
- )
134
- Appsignal::Marker.stub(:new => @marker)
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!'
135
140
  end
136
141
 
137
- context "proper setup" do
142
+ context "with overridden revision" do
138
143
  before do
139
- @transmitter = double
140
- Appsignal::Transmitter.should_receive(:new).and_return(@transmitter)
144
+ capistrano_config.set(:appsignal_revision, 'abc123')
145
+ stub_marker_request(:revision => 'abc123').to_return(:status => 200)
146
+ invoke('appsignal:deploy')
141
147
  end
142
148
 
143
- it "should add the correct marker data" do
144
- Appsignal::Marker.should_receive(:new).with(
145
- marker_data,
146
- kind_of(Appsignal::Config)
147
- ).and_return(@marker)
148
-
149
- invoke('appsignal:deploy')
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!'
150
153
  end
154
+ end
151
155
 
152
- it "should transmit data" do
153
- @transmitter.should_receive(:transmit).and_return('200')
156
+ context "with failed request" do
157
+ before do
158
+ stub_marker_request.to_return(:status => 500)
154
159
  invoke('appsignal:deploy')
155
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
156
- out_stream.string.should include('ppsignal has been notified of this deploy!')
157
160
  end
158
161
 
159
- context "with overridden revision" do
160
- before do
161
- @capistrano_config.set(:appsignal_revision, 'abc123')
162
- end
163
- it "should add the correct marker data" do
164
- Appsignal::Marker.should_receive(:new).with(
165
- {
166
- :revision => 'abc123',
167
- :user => 'batman'
168
- },
169
- kind_of(Appsignal::Config)
170
- ).and_return(@marker)
171
-
172
- invoke('appsignal:deploy')
173
- end
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!'
174
168
  end
175
169
  end
176
-
177
- it "should not transmit data" do
178
- invoke('appsignal:deploy')
179
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
180
- out_stream.string.should include('Something went wrong while trying to notify Appsignal:')
181
- end
182
170
  end
183
171
 
184
172
  context "when not active for this environment" do
185
173
  before do
186
- @capistrano_config.set(:rails_env, 'nonsense')
174
+ capistrano_config.set(:rails_env, 'nonsense')
175
+ invoke('appsignal:deploy')
187
176
  end
188
177
 
189
178
  it "should not send deploy marker" do
190
- Appsignal::Marker.should_not_receive(:new)
191
- invoke('appsignal:deploy')
192
- out_stream.string.should include("Not notifying of deploy, config is not active for environment: nonsense")
179
+ expect(out_stream.string).to include \
180
+ "Not notifying of deploy, config is not active for environment: nonsense"
193
181
  end
194
182
  end
195
183
  end
@@ -1,7 +1,7 @@
1
1
  describe Appsignal::Marker do
2
2
  let(:config) { project_fixture_config }
3
- let(:marker) {
4
- Appsignal::Marker.new(
3
+ let(:marker) do
4
+ described_class.new(
5
5
  {
6
6
  :revision => '503ce0923ed177a3ce000005',
7
7
  :repository => 'master',
@@ -10,53 +10,46 @@ describe Appsignal::Marker do
10
10
  },
11
11
  config
12
12
  )
13
- }
13
+ end
14
14
  let(:out_stream) { StringIO.new }
15
15
  around do |example|
16
16
  capture_stdout(out_stream) { example.run }
17
17
  end
18
18
 
19
- context "transmit" do
20
- let(:transmitter) { double }
21
- before do
22
- Appsignal::Transmitter.should_receive(:new).with(
23
- 'markers', config
24
- ).and_return(transmitter)
25
- end
26
-
27
- it "should transmit data" do
28
- transmitter.should_receive(:transmit).with(
29
- :revision => '503ce0923ed177a3ce000005',
30
- :repository => 'master',
31
- :user => 'batman',
32
- :rails_env => 'production'
33
- )
34
-
35
- marker.transmit
19
+ describe "#transmit" do
20
+ def stub_marker_request
21
+ stub_api_request config, "markers", marker.marker_data
36
22
  end
37
23
 
38
- it "should log status 200" do
39
- transmitter.should_receive(:transmit).and_return('200')
40
-
41
- marker.transmit
42
-
43
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
44
- out_stream.string.should include('Appsignal has been notified of this deploy!')
24
+ context "when request is valid" do
25
+ before do
26
+ stub_marker_request.to_return(:status => 200)
27
+ marker.transmit
28
+ end
29
+
30
+ it "outputs success" do
31
+ output = out_stream.string
32
+ expect(output).to include \
33
+ 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
34
+ 'Appsignal has been notified of this deploy!'
35
+ end
45
36
  end
46
37
 
47
- it "should log other status" do
48
- transmitter.should_receive(:transmit).and_return('500')
49
- transmitter.should_receive(:uri).and_return('http://localhost:3000/1/markers')
50
-
51
- marker.transmit
52
-
53
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
54
- out_stream.string.should include(
55
- 'Something went wrong while trying to notify Appsignal: 500 at http://localhost:3000/1/markers'
56
- )
57
- out_stream.string.should_not include(
58
- 'Appsignal has been notified of this deploy!'
59
- )
38
+ context "when request is invalid" do
39
+ before do
40
+ stub_marker_request.to_return(:status => 500)
41
+ marker.transmit
42
+ end
43
+
44
+ it "outputs failure" do
45
+ output = out_stream.string
46
+ expect(output).to include \
47
+ 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
48
+ "Something went wrong while trying to notify Appsignal: 500 at "\
49
+ "#{config[:endpoint]}/1/markers"
50
+ expect(output).to_not include \
51
+ 'Appsignal has been notified of this deploy!'
52
+ end
60
53
  end
61
54
  end
62
55
  end
@@ -27,7 +27,7 @@ describe Appsignal::Transmitter do
27
27
  "&environment=production&gem_version=#{Appsignal::VERSION}"\
28
28
  "&hostname=#{config.config_hash[:hostname]}&name=TestApp"
29
29
  ).with(
30
- :body => Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED),
30
+ :body => Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}"),
31
31
  :headers => {
32
32
  'Content-Encoding' => 'gzip',
33
33
  'Content-Type' => 'application/json; charset=UTF-8',
@@ -84,13 +84,9 @@ describe Appsignal::Transmitter do
84
84
  end
85
85
 
86
86
  describe "#http_post" do
87
- before do
88
- Socket.stub(:gethostname => 'app1.local')
89
- end
90
-
91
87
  subject { instance.send(:http_post, 'the' => 'payload') }
92
88
 
93
- its(:body) { should eq Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED) }
89
+ its(:body) { should eq Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}") }
94
90
  its(:path) { should eq instance.uri.request_uri }
95
91
 
96
92
  it "should have the correct headers" do
@@ -0,0 +1,10 @@
1
+ describe Appsignal::Utils::Gzip do
2
+ describe ".compress" do
3
+ let(:value) { "foo" }
4
+ subject { described_class.compress(value).force_encoding("UTF-8") }
5
+
6
+ it "returns a gziped value" do
7
+ expect(subject).to eq("x\u0001K\xCB\xCF\a\u0000\u0002\x82\u0001E")
8
+ end
9
+ end
10
+ end
@@ -130,6 +130,7 @@ RSpec.configure do |config|
130
130
  config.include NotificationHelpers
131
131
  config.include TimeHelpers
132
132
  config.include TransactionHelpers
133
+ config.include ApiRequestHelper
133
134
 
134
135
  config.before :all do
135
136
  FileUtils.rm_rf(tmp_dir)
@@ -0,0 +1,19 @@
1
+ module ApiRequestHelper
2
+ def stub_api_request(config, path, body)
3
+ body = Appsignal::Utils::Gzip.compress(Appsignal::Utils::JSON.generate(body))
4
+ stub_request(:post, "#{config[:endpoint]}/1/#{path}").with(
5
+ :body => body,
6
+ :query => {
7
+ :api_key => config[:push_api_key],
8
+ :name => config[:name],
9
+ :environment => config.env,
10
+ :hostname => config[:hostname],
11
+ :gem_version => Appsignal::VERSION
12
+ },
13
+ :headers => {
14
+ 'Content-Encoding' => 'gzip',
15
+ 'Content-Type' => 'application/json; charset=UTF-8',
16
+ }
17
+ )
18
+ end
19
+ 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.6.beta.1
4
+ version: 1.3.6
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-26 00:00:00.000000000 Z
12
+ date: 2016-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -272,6 +272,7 @@ files:
272
272
  - spec/lib/appsignal/transaction_spec.rb
273
273
  - spec/lib/appsignal/transmitter_spec.rb
274
274
  - spec/lib/appsignal/update_active_support_spec.rb
275
+ - spec/lib/appsignal/utils/gzip_spec.rb
275
276
  - spec/lib/appsignal/utils/params_sanitizer_spec.rb
276
277
  - spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
277
278
  - spec/lib/appsignal/utils_spec.rb
@@ -281,6 +282,7 @@ files:
281
282
  - spec/support/delegate_matcher.rb
282
283
  - spec/support/fixtures/generated_config.yml
283
284
  - spec/support/fixtures/uploaded_file.txt
285
+ - spec/support/helpers/api_request_helper.rb
284
286
  - spec/support/helpers/config_helpers.rb
285
287
  - spec/support/helpers/directory_helper.rb
286
288
  - spec/support/helpers/env_helpers.rb
@@ -314,9 +316,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
314
316
  version: '1.9'
315
317
  required_rubygems_version: !ruby/object:Gem::Requirement
316
318
  requirements:
317
- - - ">"
319
+ - - ">="
318
320
  - !ruby/object:Gem::Version
319
- version: 1.3.1
321
+ version: '0'
320
322
  requirements: []
321
323
  rubyforge_project:
322
324
  rubygems_version: 2.4.5
@@ -378,6 +380,7 @@ test_files:
378
380
  - spec/lib/appsignal/transaction_spec.rb
379
381
  - spec/lib/appsignal/transmitter_spec.rb
380
382
  - spec/lib/appsignal/update_active_support_spec.rb
383
+ - spec/lib/appsignal/utils/gzip_spec.rb
381
384
  - spec/lib/appsignal/utils/params_sanitizer_spec.rb
382
385
  - spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
383
386
  - spec/lib/appsignal/utils_spec.rb
@@ -387,6 +390,7 @@ test_files:
387
390
  - spec/support/delegate_matcher.rb
388
391
  - spec/support/fixtures/generated_config.yml
389
392
  - spec/support/fixtures/uploaded_file.txt
393
+ - spec/support/helpers/api_request_helper.rb
390
394
  - spec/support/helpers/config_helpers.rb
391
395
  - spec/support/helpers/directory_helper.rb
392
396
  - spec/support/helpers/env_helpers.rb