appsignal 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +22 -0
- data/README.md +9 -5
- data/appsignal.gemspec +1 -1
- data/ext/agent.yml +11 -11
- data/lib/appsignal.rb +8 -9
- data/lib/appsignal/cli.rb +12 -14
- data/lib/appsignal/cli/diagnose.rb +82 -31
- data/lib/appsignal/cli/helpers.rb +67 -0
- data/lib/appsignal/cli/install.rb +22 -69
- data/lib/appsignal/config.rb +3 -3
- data/lib/appsignal/integrations/padrino.rb +1 -1
- data/lib/appsignal/integrations/railtie.rb +1 -1
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +18 -19
- data/spec/lib/appsignal/capistrano3_spec.rb +16 -17
- data/spec/lib/appsignal/cli/demo_spec.rb +4 -4
- data/spec/lib/appsignal/cli/diagnose_spec.rb +237 -88
- data/spec/lib/appsignal/cli/helpers_spec.rb +99 -0
- data/spec/lib/appsignal/cli/install_spec.rb +486 -352
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +5 -6
- data/spec/lib/appsignal/cli_spec.rb +24 -44
- data/spec/lib/appsignal/config_spec.rb +39 -8
- data/spec/lib/appsignal/demo_spec.rb +13 -8
- data/spec/lib/appsignal/hooks_spec.rb +3 -0
- data/spec/lib/appsignal/integrations/object_spec.rb +35 -26
- data/spec/lib/appsignal/marker_spec.rb +10 -14
- data/spec/lib/appsignal_spec.rb +83 -60
- data/spec/spec_helper.rb +8 -7
- data/spec/support/helpers/cli_helpers.rb +9 -0
- data/spec/support/helpers/std_streams_helper.rb +44 -13
- data/spec/support/helpers/transaction_helpers.rb +2 -2
- metadata +9 -6
@@ -1,495 +1,629 @@
|
|
1
|
-
require
|
1
|
+
require "appsignal/cli"
|
2
2
|
|
3
3
|
describe Appsignal::CLI::Install do
|
4
|
-
|
5
|
-
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
|
4
|
+
include CLIHelpers
|
5
|
+
|
6
|
+
let(:out_stream) { std_stream }
|
7
|
+
let(:output) { out_stream.read }
|
8
|
+
let(:push_api_key) { "my_key" }
|
9
|
+
let(:config) { Appsignal::Config.new(tmp_dir, "") }
|
10
|
+
let(:config_file_path) { File.join(tmp_dir, "config", "appsignal.yml") }
|
11
|
+
let(:config_file) { File.read(config_file_path) }
|
9
12
|
before do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
stub_api_validation_request
|
14
|
+
# Stub calls to speed up tests
|
15
|
+
allow(described_class).to receive(:sleep)
|
16
|
+
allow(described_class).to receive(:press_any_key)
|
17
|
+
allow(Appsignal::Demo).to receive(:transmit).and_return(true)
|
15
18
|
end
|
16
19
|
around do |example|
|
17
|
-
|
20
|
+
original_stdin = $stdin
|
21
|
+
$stdin = StringIO.new
|
22
|
+
example.run
|
23
|
+
$stdin = original_stdin
|
18
24
|
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
define :include_complete_install do
|
27
|
+
match do |actual|
|
28
|
+
actual.include?("AppSignal installation complete")
|
29
|
+
end
|
30
|
+
end
|
23
31
|
|
24
|
-
|
25
|
-
|
32
|
+
define :include_env_push_api_key do |key|
|
33
|
+
match do |actual|
|
34
|
+
actual.include?("export APPSIGNAL_PUSH_API_KEY=#{key}")
|
26
35
|
end
|
36
|
+
end
|
37
|
+
define :include_env_app_name do |name|
|
38
|
+
match do |actual|
|
39
|
+
actual.include?("export APPSIGNAL_APP_NAME=#{name}")
|
40
|
+
end
|
41
|
+
end
|
27
42
|
|
28
|
-
|
29
|
-
|
30
|
-
|
43
|
+
define :configure_app_name do |name|
|
44
|
+
match do |file_contents|
|
45
|
+
file_contents =~ /^ name: "#{name}"/
|
46
|
+
end
|
47
|
+
end
|
48
|
+
define :configure_push_api_key do |key|
|
49
|
+
match do |file_contents|
|
50
|
+
file_contents =~ /^ push_api_key: "#{key}"/
|
51
|
+
end
|
52
|
+
end
|
53
|
+
define :configure_environment do |env|
|
54
|
+
match do |file_contents|
|
55
|
+
file_contents =~ /^#{env}:$/
|
56
|
+
end
|
57
|
+
end
|
58
|
+
define :include_file_config do
|
59
|
+
match do |log|
|
60
|
+
log.include?("Config file written to config/appsignal.yml")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
define :include_demo_transmission do
|
65
|
+
match do |log|
|
66
|
+
log.include?("Sending example data to AppSignal") &&
|
67
|
+
log.include?("Example data sent!")
|
68
|
+
end
|
69
|
+
end
|
31
70
|
|
32
|
-
|
71
|
+
def stub_api_validation_request
|
72
|
+
config[:push_api_key] = push_api_key
|
73
|
+
stub_api_request config, "auth"
|
74
|
+
end
|
33
75
|
|
34
|
-
|
35
|
-
end
|
76
|
+
alias_method :enter_app_name, :set_input
|
36
77
|
|
37
|
-
|
38
|
-
|
78
|
+
def choose_config_file
|
79
|
+
set_input "1"
|
80
|
+
end
|
39
81
|
|
40
|
-
|
82
|
+
def choose_environment_config
|
83
|
+
set_input "2"
|
84
|
+
end
|
41
85
|
|
42
|
-
|
86
|
+
def run
|
87
|
+
Dir.chdir tmp_dir do
|
88
|
+
prepare_input
|
89
|
+
capture_stdout(out_stream) do
|
90
|
+
run_cli(["install", push_api_key])
|
43
91
|
end
|
44
92
|
end
|
45
93
|
end
|
46
94
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
it "should install with environment variables" do
|
51
|
-
cli.should_receive(:gets).once.and_return('n')
|
52
|
-
cli.should_receive(:gets).once.and_return('2')
|
95
|
+
shared_examples "push_api_key validation" do
|
96
|
+
context "without key" do
|
97
|
+
let(:push_api_key) {}
|
53
98
|
|
54
|
-
|
99
|
+
it "does not install" do
|
100
|
+
run
|
55
101
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
out_stream.string.should include("AppSignal installation complete")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should install with config file" do
|
64
|
-
cli.should_receive(:gets).once.and_return('n')
|
65
|
-
cli.should_receive(:gets).once.and_return('1')
|
66
|
-
cli.should_receive(:write_config_file)
|
67
|
-
|
68
|
-
cli.run('key', config)
|
102
|
+
expect(output).to include "Problem encountered:",
|
103
|
+
"No push API key entered"
|
104
|
+
end
|
105
|
+
end
|
69
106
|
|
70
|
-
|
71
|
-
|
72
|
-
out_stream.string.should include("Installing for Ruby on Rails")
|
73
|
-
out_stream.string.should include("AppSignal installation complete")
|
74
|
-
end
|
107
|
+
context "with key" do
|
108
|
+
let(:push_api_key) { "my_key" }
|
75
109
|
|
76
|
-
|
77
|
-
|
78
|
-
cli.should_receive(:gets).once.and_return('Appname')
|
79
|
-
cli.should_receive(:gets).once.and_return('2')
|
110
|
+
context "when the key is valid" do
|
111
|
+
before { stub_api_validation_request.to_return(:status => 200) }
|
80
112
|
|
81
|
-
|
113
|
+
it "continues with the installer" do
|
114
|
+
enter_app_name "Test App"
|
115
|
+
choose_environment_config
|
116
|
+
run
|
82
117
|
|
83
|
-
|
84
|
-
out_stream.string.should include("API key valid")
|
85
|
-
out_stream.string.should include("Installing for Ruby on Rails")
|
86
|
-
out_stream.string.should include("export APPSIGNAL_PUSH_API_KEY=key")
|
87
|
-
out_stream.string.should include("export APPSIGNAL_APP_NAME=Appname")
|
88
|
-
out_stream.string.should include("AppSignal installation complete")
|
118
|
+
expect(output).to include("Validating API key...", "API key valid")
|
89
119
|
end
|
120
|
+
end
|
90
121
|
|
91
|
-
|
92
|
-
|
93
|
-
cli.should_receive(:gets).once.and_return('Appname')
|
94
|
-
cli.should_receive(:gets).once.and_return('1')
|
95
|
-
cli.should_receive(:write_config_file)
|
96
|
-
|
97
|
-
cli.run('key', config)
|
122
|
+
context "when the key is invalid" do
|
123
|
+
before { stub_api_validation_request.to_return(:status => 402) }
|
98
124
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
out_stream.string.should include("AppSignal installation complete")
|
125
|
+
it "prints an error" do
|
126
|
+
run
|
127
|
+
expect(output).to include "API key 'my_key' is not valid"
|
103
128
|
end
|
104
129
|
end
|
105
130
|
|
106
|
-
|
131
|
+
context "when there is an error validating" do
|
107
132
|
before do
|
108
|
-
|
133
|
+
expect(Appsignal::AuthCheck).to receive(:new).and_raise(StandardError)
|
109
134
|
end
|
110
135
|
|
111
|
-
|
112
|
-
|
113
|
-
|
136
|
+
it "prints an error" do
|
137
|
+
run
|
138
|
+
expect(output).to include "There was an error validating your API key"
|
139
|
+
end
|
114
140
|
end
|
141
|
+
end
|
142
|
+
end
|
115
143
|
|
116
|
-
|
117
|
-
|
144
|
+
shared_examples "requires an application name" do
|
145
|
+
before do
|
146
|
+
enter_app_name ""
|
147
|
+
enter_app_name "Test app"
|
148
|
+
choose_environment_config
|
149
|
+
run
|
150
|
+
end
|
118
151
|
|
119
|
-
|
120
|
-
|
152
|
+
it "requires an application name" do
|
153
|
+
expect(output.scan(/Enter application name:/).length).to eq(2)
|
121
154
|
end
|
122
155
|
end
|
123
156
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
cli.should_receive(:gets).once.and_return('Appname')
|
129
|
-
cli.should_receive(:gets).once.and_return('2')
|
157
|
+
shared_examples "capistrano install" do
|
158
|
+
let(:capfile) { File.join(tmp_dir, "Capfile") }
|
159
|
+
before do
|
160
|
+
FileUtils.mkdir_p(tmp_dir)
|
130
161
|
|
131
|
-
|
162
|
+
enter_app_name "foo"
|
163
|
+
set_input "n"
|
164
|
+
choose_environment_config
|
165
|
+
end
|
166
|
+
after do
|
167
|
+
FileUtils.rm_rf(tmp_dir)
|
168
|
+
FileUtils.mkdir_p(tmp_dir)
|
169
|
+
end
|
132
170
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
out_stream.string.should include("export APPSIGNAL_PUSH_API_KEY=key")
|
137
|
-
out_stream.string.should include("AppSignal installation complete")
|
138
|
-
end
|
171
|
+
context "without Capfile" do
|
172
|
+
it "does nothing" do
|
173
|
+
run
|
139
174
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
175
|
+
expect(output).to_not include "Adding AppSignal integration to Capfile"
|
176
|
+
expect(File.exist?(capfile)).to be_false
|
177
|
+
end
|
178
|
+
end
|
144
179
|
|
145
|
-
|
180
|
+
context "with Capfile" do
|
181
|
+
context "when already installed" do
|
182
|
+
before { File.open(capfile, "w") { |f| f.write("require 'appsignal/capistrano'") } }
|
146
183
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
184
|
+
it "does not add another require to Capfile" do
|
185
|
+
run
|
186
|
+
|
187
|
+
expect(output).to_not include "Adding AppSignal integration to Capfile"
|
188
|
+
expect(File.read(capfile).scan(/appsignal/).count).to eq(1)
|
151
189
|
end
|
152
190
|
end
|
153
191
|
|
154
|
-
|
155
|
-
|
192
|
+
context "when not installed" do
|
193
|
+
before { FileUtils.touch(capfile) }
|
194
|
+
|
195
|
+
it "adds a require to Capfile" do
|
196
|
+
run
|
156
197
|
|
157
|
-
|
198
|
+
expect(output).to include "Adding AppSignal integration to Capfile"
|
199
|
+
expect(File.read(capfile)).to include "require 'appsignal/capistrano'"
|
200
|
+
end
|
158
201
|
end
|
159
202
|
end
|
160
203
|
end
|
161
204
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
cli.run('key', config)
|
170
|
-
|
171
|
-
out_stream.string.should include("Validating API key...")
|
172
|
-
out_stream.string.should include("API key valid")
|
173
|
-
out_stream.string.should include("Installing for Padrino")
|
174
|
-
out_stream.string.should include("export APPSIGNAL_PUSH_API_KEY=key")
|
175
|
-
out_stream.string.should include("AppSignal installation complete")
|
176
|
-
end
|
205
|
+
shared_examples "windows installation" do
|
206
|
+
before do
|
207
|
+
allow(Gem).to receive(:win_platform?).and_return(true)
|
208
|
+
expect(Appsignal::Demo).to_not receive(:transmit)
|
209
|
+
run
|
210
|
+
end
|
177
211
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
212
|
+
it "prints a warning for windows" do
|
213
|
+
expect(output).to include("The AppSignal agent currently does not work on Windows")
|
214
|
+
expect(output).to include("test/staging/production environment")
|
215
|
+
end
|
216
|
+
end
|
182
217
|
|
183
|
-
|
218
|
+
shared_examples "demo data" do
|
219
|
+
context "with demo data sent" do
|
220
|
+
before do
|
221
|
+
expect(Appsignal::Demo).to receive(:transmit).and_return(true)
|
222
|
+
run
|
223
|
+
end
|
184
224
|
|
185
|
-
|
186
|
-
|
187
|
-
out_stream.string.should include("Installing for Padrino")
|
188
|
-
out_stream.string.should include("AppSignal installation complete")
|
189
|
-
end
|
225
|
+
it "prints sending demo data" do
|
226
|
+
expect(output).to include "Sending example data to AppSignal", "Example data sent!"
|
190
227
|
end
|
228
|
+
end
|
191
229
|
|
192
|
-
|
193
|
-
|
230
|
+
context "without demo data being sent" do
|
231
|
+
before do
|
232
|
+
expect(Appsignal::Demo).to receive(:transmit).and_return(false)
|
233
|
+
run
|
234
|
+
end
|
194
235
|
|
195
|
-
|
236
|
+
it "prints that it couldn't send the demo data" do
|
237
|
+
expect(output).to include "Sending example data to AppSignal",
|
238
|
+
"Couldn't start the AppSignal agent and send example data",
|
239
|
+
"`appsignal diagnose`"
|
196
240
|
end
|
197
241
|
end
|
198
242
|
end
|
199
243
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
244
|
+
if rails_present?
|
245
|
+
context "with rails" do
|
246
|
+
let(:installation_instructions) { ["Installing for Ruby on Rails"] }
|
247
|
+
let(:app_name) { "MyApp" }
|
248
|
+
let(:config_dir) { File.join(tmp_dir, "config") }
|
249
|
+
let(:environments_dir) { File.join(config_dir, "environments") }
|
250
|
+
before do
|
251
|
+
# Fake Rails directory
|
252
|
+
FileUtils.mkdir_p(config_dir)
|
253
|
+
FileUtils.mkdir_p(environments_dir)
|
254
|
+
FileUtils.touch(File.join(config_dir, "application.rb"))
|
255
|
+
FileUtils.touch(File.join(environments_dir, "development.rb"))
|
256
|
+
FileUtils.touch(File.join(environments_dir, "staging.rb"))
|
257
|
+
FileUtils.touch(File.join(environments_dir, "production.rb"))
|
258
|
+
enter_app_name app_name
|
259
|
+
end
|
208
260
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
261
|
+
describe "environments" do
|
262
|
+
before do
|
263
|
+
File.delete(File.join(environments_dir, "development.rb"))
|
264
|
+
File.delete(File.join(environments_dir, "staging.rb"))
|
265
|
+
set_input "n"
|
266
|
+
choose_config_file
|
214
267
|
end
|
215
268
|
|
216
|
-
it "
|
217
|
-
|
218
|
-
cli.should_receive(:gets).once.and_return('1')
|
219
|
-
cli.should_receive(:write_config_file)
|
269
|
+
it "only configures the available environments" do
|
270
|
+
run
|
220
271
|
|
221
|
-
|
272
|
+
expect(output).to include_file_config
|
273
|
+
expect(config_file).to configure_app_name(app_name)
|
274
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
275
|
+
expect(config_file).to_not configure_environment("development")
|
276
|
+
expect(config_file).to_not configure_environment("staging")
|
277
|
+
expect(config_file).to configure_environment("production")
|
222
278
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
out_stream.string.should include("AppSignal installation complete")
|
279
|
+
expect(output).to include(*installation_instructions)
|
280
|
+
expect(output).to include_complete_install
|
281
|
+
expect(output).to include_demo_transmission
|
227
282
|
end
|
228
283
|
end
|
229
284
|
|
230
|
-
|
231
|
-
|
285
|
+
context "without custom name" do
|
286
|
+
before { set_input "n" }
|
232
287
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
288
|
+
it_behaves_like "push_api_key validation"
|
289
|
+
|
290
|
+
context "with configuration using environment variables" do
|
291
|
+
before { choose_environment_config }
|
292
|
+
|
293
|
+
it_behaves_like "windows installation"
|
294
|
+
it_behaves_like "capistrano install"
|
295
|
+
it_behaves_like "demo data"
|
296
|
+
|
297
|
+
it "prints environment variables" do
|
298
|
+
run
|
237
299
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
300
|
+
expect(output).to include_env_push_api_key(push_api_key)
|
301
|
+
expect(output).to_not include_env_app_name
|
302
|
+
end
|
303
|
+
|
304
|
+
it "completes the installation" do
|
305
|
+
run
|
243
306
|
|
244
|
-
|
245
|
-
|
246
|
-
|
307
|
+
expect(output).to include(*installation_instructions)
|
308
|
+
expect(output).to include_complete_install
|
309
|
+
end
|
247
310
|
end
|
248
|
-
end
|
249
311
|
|
250
|
-
|
251
|
-
|
312
|
+
context "with configuration using a configuration file" do
|
313
|
+
before { choose_config_file }
|
252
314
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
end
|
315
|
+
it_behaves_like "windows installation"
|
316
|
+
it_behaves_like "capistrano install"
|
317
|
+
it_behaves_like "demo data"
|
257
318
|
|
258
|
-
|
259
|
-
|
319
|
+
it "writes configuration to file" do
|
320
|
+
run
|
260
321
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
322
|
+
expect(output).to include_file_config
|
323
|
+
expect(config_file).to configure_app_name(app_name)
|
324
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
325
|
+
expect(config_file).to configure_environment("development")
|
326
|
+
expect(config_file).to configure_environment("staging")
|
327
|
+
expect(config_file).to configure_environment("production")
|
328
|
+
end
|
265
329
|
|
266
|
-
|
267
|
-
|
330
|
+
it "completes the installation" do
|
331
|
+
run
|
268
332
|
|
269
|
-
|
270
|
-
|
271
|
-
|
333
|
+
expect(output).to include(*installation_instructions)
|
334
|
+
expect(output).to include_complete_install
|
335
|
+
end
|
336
|
+
end
|
272
337
|
end
|
273
338
|
|
274
|
-
|
275
|
-
|
276
|
-
|
339
|
+
context "with custom name" do
|
340
|
+
let(:app_name) { "Custom name" }
|
341
|
+
before { set_input "y" }
|
277
342
|
|
278
|
-
|
279
|
-
it "should output three periods" do
|
280
|
-
cli.periods
|
281
|
-
out_stream.string.should include('...')
|
282
|
-
end
|
283
|
-
end
|
343
|
+
it_behaves_like "push_api_key validation"
|
284
344
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
345
|
+
it "requires the custom name" do
|
346
|
+
enter_app_name ""
|
347
|
+
enter_app_name app_name
|
348
|
+
choose_environment_config
|
349
|
+
run
|
290
350
|
|
291
|
-
|
292
|
-
|
293
|
-
out_stream.string.should include('Press any key')
|
294
|
-
end
|
295
|
-
end
|
351
|
+
expect(output.scan(/Choose app's display name:/).length).to eq(2)
|
352
|
+
end
|
296
353
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
354
|
+
context "with configuration using environment variables" do
|
355
|
+
before do
|
356
|
+
enter_app_name app_name
|
357
|
+
choose_environment_config
|
358
|
+
end
|
302
359
|
|
303
|
-
|
304
|
-
|
360
|
+
it_behaves_like "windows installation"
|
361
|
+
it_behaves_like "capistrano install"
|
362
|
+
it_behaves_like "demo data"
|
305
363
|
|
306
|
-
|
307
|
-
|
308
|
-
cli.should_receive(:gets).once.and_return('nonsense')
|
309
|
-
cli.should_receive(:gets).once.and_return('n')
|
364
|
+
it "prints environment variables" do
|
365
|
+
run
|
310
366
|
|
311
|
-
|
312
|
-
|
313
|
-
|
367
|
+
expect(output).to include_env_push_api_key(push_api_key)
|
368
|
+
expect(output).to include_env_app_name(app_name)
|
369
|
+
end
|
370
|
+
|
371
|
+
it "completes the installation" do
|
372
|
+
run
|
373
|
+
|
374
|
+
expect(output).to include(*installation_instructions)
|
375
|
+
expect(output).to include_complete_install
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
context "with configuration using a configuration file" do
|
380
|
+
before do
|
381
|
+
enter_app_name app_name
|
382
|
+
choose_config_file
|
383
|
+
end
|
314
384
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
cli.should_receive(:gets).once.and_return('value')
|
385
|
+
it_behaves_like "windows installation"
|
386
|
+
it_behaves_like "capistrano install"
|
387
|
+
it_behaves_like "demo data"
|
319
388
|
|
320
|
-
|
389
|
+
it "writes configuration to file" do
|
390
|
+
run
|
391
|
+
|
392
|
+
expect(output).to include_file_config
|
393
|
+
expect(config_file).to configure_app_name(app_name)
|
394
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
395
|
+
expect(config_file).to configure_environment("development")
|
396
|
+
expect(config_file).to configure_environment("staging")
|
397
|
+
expect(config_file).to configure_environment("production")
|
398
|
+
end
|
399
|
+
|
400
|
+
it "completes the installation" do
|
401
|
+
run
|
402
|
+
|
403
|
+
expect(output).to include(*installation_instructions)
|
404
|
+
expect(output).to include_complete_install
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
321
408
|
end
|
322
409
|
end
|
323
410
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
411
|
+
if sinatra_present? && !padrino_present? && !rails_present?
|
412
|
+
context "with sinatra" do
|
413
|
+
it_behaves_like "push_api_key validation"
|
414
|
+
it_behaves_like "requires an application name"
|
415
|
+
|
416
|
+
describe "sinatra specific tests" do
|
417
|
+
let(:installation_instructions) do
|
418
|
+
[
|
419
|
+
"Installing for Sinatra",
|
420
|
+
"Sinatra requires some manual configuration.",
|
421
|
+
"require 'appsignal/integrations/sinatra'",
|
422
|
+
"http://docs.appsignal.com/getting-started/supported-frameworks.html#sinatra"
|
423
|
+
]
|
424
|
+
end
|
425
|
+
let(:app_name) { "Test app" }
|
426
|
+
before { enter_app_name app_name }
|
329
427
|
|
330
|
-
|
331
|
-
|
332
|
-
cli.should_receive(:gets).once.and_return('2')
|
428
|
+
describe "configuration with environment variables" do
|
429
|
+
before { choose_environment_config }
|
333
430
|
|
334
|
-
|
431
|
+
it_behaves_like "windows installation"
|
432
|
+
it_behaves_like "capistrano install"
|
433
|
+
it_behaves_like "demo data"
|
335
434
|
|
336
|
-
|
337
|
-
|
338
|
-
out_stream.string.should include("export APPSIGNAL_PUSH_API_KEY=key")
|
339
|
-
end
|
435
|
+
it "prints environment variables" do
|
436
|
+
run
|
340
437
|
|
341
|
-
|
342
|
-
|
438
|
+
expect(output).to include_env_push_api_key(push_api_key)
|
439
|
+
expect(output).to include_env_app_name(app_name)
|
440
|
+
end
|
343
441
|
|
344
|
-
|
442
|
+
it "completes the installation" do
|
443
|
+
run
|
345
444
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
445
|
+
expect(output).to include(*installation_instructions)
|
446
|
+
expect(output).to include_complete_install
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
describe "configure with a configuration file" do
|
451
|
+
before { choose_config_file }
|
352
452
|
|
353
|
-
|
354
|
-
|
355
|
-
|
453
|
+
it_behaves_like "windows installation"
|
454
|
+
it_behaves_like "capistrano install"
|
455
|
+
it_behaves_like "demo data"
|
356
456
|
|
357
|
-
|
358
|
-
|
359
|
-
:app_name => config[:name],
|
360
|
-
:environments => []
|
361
|
-
)
|
457
|
+
it "writes configuration to file" do
|
458
|
+
run
|
362
459
|
|
363
|
-
|
460
|
+
expect(output).to include_file_config
|
461
|
+
expect(config_file).to configure_app_name(app_name)
|
462
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
463
|
+
expect(config_file).to configure_environment("development")
|
464
|
+
expect(config_file).to configure_environment("staging")
|
465
|
+
expect(config_file).to configure_environment("production")
|
466
|
+
end
|
364
467
|
|
365
|
-
|
366
|
-
|
468
|
+
it "completes the installation" do
|
469
|
+
run
|
470
|
+
|
471
|
+
expect(output).to include(*installation_instructions)
|
472
|
+
expect(output).to include_complete_install
|
473
|
+
end
|
474
|
+
end
|
367
475
|
end
|
368
476
|
end
|
477
|
+
end
|
369
478
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
479
|
+
if padrino_present?
|
480
|
+
context "with padrino" do
|
481
|
+
it_behaves_like "push_api_key validation"
|
482
|
+
it_behaves_like "requires an application name"
|
483
|
+
|
484
|
+
describe "padrino specific tests" do
|
485
|
+
let(:installation_instructions) do
|
486
|
+
[
|
487
|
+
"Installing for Padrino",
|
488
|
+
"Padrino requires some manual configuration.",
|
489
|
+
"http://docs.appsignal.com/getting-started/supported-frameworks.html#padrino"
|
490
|
+
]
|
491
|
+
end
|
492
|
+
let(:app_name) { "Test app" }
|
493
|
+
before { enter_app_name app_name }
|
380
494
|
|
381
|
-
|
382
|
-
|
495
|
+
describe "configuration with environment variables" do
|
496
|
+
before { choose_environment_config }
|
383
497
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
end
|
388
|
-
end
|
498
|
+
it_behaves_like "windows installation"
|
499
|
+
it_behaves_like "capistrano install"
|
500
|
+
it_behaves_like "demo data"
|
389
501
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
502
|
+
it "prints environment variables" do
|
503
|
+
run
|
504
|
+
|
505
|
+
expect(output).to include_env_push_api_key(push_api_key)
|
506
|
+
expect(output).to include_env_app_name(app_name)
|
395
507
|
end
|
396
508
|
|
397
|
-
it "
|
398
|
-
|
399
|
-
|
509
|
+
it "completes the installation" do
|
510
|
+
run
|
511
|
+
|
512
|
+
expect(output).to include(*installation_instructions)
|
513
|
+
expect(output).to include_complete_install
|
400
514
|
end
|
401
515
|
end
|
402
516
|
|
403
|
-
|
404
|
-
before
|
405
|
-
|
406
|
-
|
517
|
+
describe "configure with a configuration file" do
|
518
|
+
before { choose_config_file }
|
519
|
+
|
520
|
+
it_behaves_like "windows installation"
|
521
|
+
it_behaves_like "capistrano install"
|
522
|
+
it_behaves_like "demo data"
|
523
|
+
|
524
|
+
it "writes configuration to file" do
|
525
|
+
run
|
526
|
+
|
527
|
+
expect(output).to include_file_config
|
528
|
+
expect(config_file).to configure_app_name(app_name)
|
529
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
530
|
+
expect(config_file).to configure_environment("development")
|
531
|
+
expect(config_file).to configure_environment("staging")
|
532
|
+
expect(config_file).to configure_environment("production")
|
407
533
|
end
|
408
534
|
|
409
|
-
it "
|
410
|
-
|
411
|
-
|
535
|
+
it "completes the installation" do
|
536
|
+
run
|
537
|
+
|
538
|
+
expect(output).to include(*installation_instructions)
|
539
|
+
expect(output).to include_complete_install
|
412
540
|
end
|
413
541
|
end
|
414
542
|
end
|
415
543
|
end
|
416
544
|
end
|
417
545
|
|
418
|
-
|
419
|
-
|
546
|
+
if grape_present?
|
547
|
+
context "with grape" do
|
548
|
+
it_behaves_like "push_api_key validation"
|
549
|
+
it_behaves_like "requires an application name"
|
550
|
+
|
551
|
+
describe "grape specific tests" do
|
552
|
+
let(:installation_instructions) do
|
553
|
+
[
|
554
|
+
"Installing for Grape",
|
555
|
+
"Manual Grape configuration needed",
|
556
|
+
"http://docs.appsignal.com/getting-started/supported-frameworks.html#grape"
|
557
|
+
]
|
558
|
+
end
|
559
|
+
let(:app_name) { "Test app" }
|
560
|
+
before { enter_app_name app_name }
|
420
561
|
|
421
|
-
|
422
|
-
|
423
|
-
Gem.stub(:win_platform? => true)
|
424
|
-
cli.done_notice
|
425
|
-
end
|
562
|
+
describe "configuration with environment variables" do
|
563
|
+
before { choose_environment_config }
|
426
564
|
|
427
|
-
|
428
|
-
|
429
|
-
|
565
|
+
it_behaves_like "windows installation"
|
566
|
+
it_behaves_like "capistrano install"
|
567
|
+
it_behaves_like "demo data"
|
430
568
|
|
431
|
-
|
432
|
-
|
569
|
+
it "prints environment variables" do
|
570
|
+
run
|
433
571
|
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
cli.done_notice
|
438
|
-
end
|
572
|
+
expect(output).to include_env_push_api_key(push_api_key)
|
573
|
+
expect(output).to include_env_app_name(app_name)
|
574
|
+
end
|
439
575
|
|
440
|
-
|
441
|
-
|
442
|
-
end
|
443
|
-
end
|
576
|
+
it "completes the installation" do
|
577
|
+
run
|
444
578
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
cli.done_notice
|
579
|
+
expect(output).to include(*installation_instructions)
|
580
|
+
expect(output).to include_complete_install
|
581
|
+
end
|
449
582
|
end
|
450
583
|
|
451
|
-
|
452
|
-
|
453
|
-
"Couldn't start the AppSignal agent and send example data",
|
454
|
-
"`appsignal diagnose`"
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
584
|
+
describe "configure with a configuration file" do
|
585
|
+
before { choose_config_file }
|
459
586
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
end
|
587
|
+
it_behaves_like "windows installation"
|
588
|
+
it_behaves_like "capistrano install"
|
589
|
+
it_behaves_like "demo data"
|
464
590
|
|
465
|
-
|
466
|
-
|
467
|
-
:push_api_key => 'key',
|
468
|
-
:app_name => 'App name',
|
469
|
-
:environments => [:staging, :production]
|
470
|
-
)
|
591
|
+
it "writes configuration to file" do
|
592
|
+
run
|
471
593
|
|
472
|
-
|
594
|
+
expect(output).to include_file_config
|
595
|
+
expect(config_file).to configure_app_name(app_name)
|
596
|
+
expect(config_file).to configure_push_api_key(push_api_key)
|
597
|
+
expect(config_file).to configure_environment("development")
|
598
|
+
expect(config_file).to configure_environment("staging")
|
599
|
+
expect(config_file).to configure_environment("production")
|
600
|
+
end
|
473
601
|
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
602
|
+
it "completes the installation" do
|
603
|
+
run
|
604
|
+
|
605
|
+
expect(output).to include(*installation_instructions)
|
606
|
+
expect(output).to include_complete_install
|
607
|
+
end
|
608
|
+
end
|
609
|
+
end
|
478
610
|
end
|
611
|
+
end
|
479
612
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
:app_name => 'App name',
|
484
|
-
:environments => []
|
485
|
-
)
|
613
|
+
if !rails_present? && !sinatra_present? && !padrino_present? && !grape_present?
|
614
|
+
context "with unknown framework" do
|
615
|
+
let(:push_api_key) { "my_key" }
|
486
616
|
|
487
|
-
|
617
|
+
it_behaves_like "push_api_key validation"
|
488
618
|
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
619
|
+
it "prints a message about unknown framework" do
|
620
|
+
run
|
621
|
+
|
622
|
+
expect(output).to include "We could not detect which framework you are using."
|
623
|
+
expect(output).to_not include_env_push_api_key
|
624
|
+
expect(output).to_not include_env_app_name
|
625
|
+
expect(File.exist?(config_file_path)).to be_false
|
626
|
+
end
|
493
627
|
end
|
494
628
|
end
|
495
629
|
end
|