appsignal 0.5.5 → 0.6.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ac8120b63e45fdea0861e414b1c64bff97abb942
4
- data.tar.gz: 25b2c51d536d5dae8a637ff109c436776942df8a
5
- SHA512:
6
- metadata.gz: 6316bff3682062da20c389a3b875f06f9a91e3e9e078380ec61d57ad1b01cdbe7ae4d6668b491000b7f1b563c0e959b486ef513bc66e621cbc88578cba0d873d
7
- data.tar.gz: ab0be93d7752313f9970c1c9c91955a1b55d8cbadc13003d90e1f89fa70b1f03daf8922404ca49a45cd9b1a36d034deae36c5a8ac5b28f29f9d6c36c8a8695bf
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjNjZDg5OTdhZGVjYTJmZDJhODU2ZDg5M2QzMjQ5MzQ0NGUxMmM4Nw==
5
+ data.tar.gz: !binary |-
6
+ NTRiMWI0ODg1ZDllOTliMzNjMGE4Njc2MjRkYzE1NDA0ZTFlYmRhOQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ M2QxYzYzN2ViNTE5ZjFhMGI5ZDgyZmJjY2I3YjdhMTgxMjM0NTlmNjM0ZDJm
10
+ NzFhMzg5MWI5MmY0NTE0NTBiNGM2YmFjMGNjZjdmMTJkODBjMTUxYTc0MTVj
11
+ MGIzOGFkYTNlNzlmODJjM2ZkZjdlZTdmNGU4ZDIzNmY1N2ZmODE=
12
+ data.tar.gz: !binary |-
13
+ NzdkNmI1NWM4Mjc4Mjc4YzBhODU4YjAwYzA2NjdiNGRjYjBiZmU0M2I1ODg0
14
+ NjVhMzI5OTkyMzk3OTk5OWMzMTcwZDA0Mjc5ZDYyNjc0MzI0MmYzYTE4ODM0
15
+ Mzc1NGVkZGVjYjFkYjg2ZjM0ZTU3ODIzOTcxMjJiY2MxOWQ4MTc=
data/.travis.yml CHANGED
@@ -21,6 +21,7 @@ matrix:
21
21
  - rvm: 1.8.7
22
22
  gemfile: gemfiles/edge.gemfile
23
23
  allow_failures:
24
+ - 1.8.7
24
25
  - gemfile: gemfiles/edge.gemfile
25
26
 
26
27
  script: RAILS_ENV=test bundle exec rspec spec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'appsignal/version'
2
+
1
3
  task :publish do
2
4
  NAME = 'appsignal'
3
5
  VERSION_FILE = 'lib/appsignal/version.rb'
data/appsignal.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.require_paths = ['lib']
23
23
  gem.version = Appsignal::VERSION
24
24
 
25
- gem.add_dependency 'rails', '~> 3.0'
25
+ gem.add_dependency 'rails', '>= 3.0'
26
26
  gem.add_dependency 'rake'
27
27
  gem.add_dependency 'json'
28
28
 
data/lib/appsignal.rb CHANGED
@@ -1,4 +1,8 @@
1
- raise 'This appsignal gem only works with rails' unless defined?(Rails)
1
+ begin
2
+ require "rails" unless defined?(Rails)
3
+ rescue
4
+ raise 'This appsignal gem only works with rails'
5
+ end
2
6
 
3
7
  module Appsignal
4
8
  class << self
@@ -15,6 +19,27 @@ module Appsignal
15
19
  agent.enqueue(transaction)
16
20
  end
17
21
 
22
+ def listen_for_exception(&block)
23
+ yield
24
+ rescue Exception => exception
25
+ send_exception(exception)
26
+ raise exception
27
+ end
28
+
29
+ def send_exception(exception)
30
+ unless is_ignored_exception?(exception)
31
+ Appsignal.agent
32
+ env = ENV.to_hash
33
+
34
+ transaction = Appsignal::Transaction.create(SecureRandom.uuid, env)
35
+ transaction.add_exception(
36
+ Appsignal::ExceptionNotification.new(env, exception, false)
37
+ )
38
+ transaction.complete!
39
+ Appsignal.agent.send_queue
40
+ end
41
+ end
42
+
18
43
  def transactions
19
44
  @transactions ||= {}
20
45
  end
@@ -35,6 +60,10 @@ module Appsignal
35
60
  Appsignal.logger << @in_memory_log.string
36
61
  end
37
62
 
63
+ def json
64
+ ActiveSupport::JSON
65
+ end
66
+
38
67
  def logger=(l)
39
68
  @logger = l
40
69
  end
@@ -52,13 +81,17 @@ module Appsignal
52
81
  def active?
53
82
  config && config[:active] == true
54
83
  end
84
+
85
+ def is_ignored_exception?(exception)
86
+ Array.wrap(Appsignal.config[:ignore_exceptions]).
87
+ include?(exception.class.name)
88
+ end
55
89
  end
56
90
  end
57
91
 
58
92
  require 'appsignal/agent'
59
93
  require 'appsignal/aggregator'
60
94
  require 'appsignal/auth_check'
61
- require 'appsignal/cli'
62
95
  require 'appsignal/config'
63
96
  require 'appsignal/exception_notification'
64
97
  require 'appsignal/integrations/passenger'
@@ -4,7 +4,6 @@ module Appsignal
4
4
 
5
5
  attr_reader :environment, :logger
6
6
  attr_accessor :transmitter
7
- delegate :uri, :to => :transmitter
8
7
 
9
8
  def initialize(*args)
10
9
  @environment = args.shift
@@ -13,6 +12,10 @@ module Appsignal
13
12
  @logger = options[:logger]
14
13
  end
15
14
 
15
+ def uri
16
+ transmitter.uri
17
+ end
18
+
16
19
  def config
17
20
  @config ||= Appsignal::Config.new(Rails.root, environment, logger).load
18
21
  end
@@ -23,5 +26,25 @@ module Appsignal
23
26
  )
24
27
  transmitter.transmit({})
25
28
  end
29
+
30
+ def perform_with_result
31
+ begin
32
+ status = perform
33
+ case status
34
+ when '200'
35
+ result = 'AppSignal has confirmed authorization!'
36
+ when '401'
37
+ result = 'API key not valid with AppSignal...'
38
+ else
39
+ result = 'Could not confirm authorization: '\
40
+ "#{status.nil? ? 'nil' : status}"
41
+ end
42
+ [status, result]
43
+ rescue Exception => e
44
+ result = 'Something went wrong while trying to '\
45
+ "authenticate with AppSignal: #{e}"
46
+ [nil, result]
47
+ end
48
+ end
26
49
  end
27
50
  end
data/lib/appsignal/cli.rb CHANGED
@@ -17,7 +17,8 @@ module Appsignal
17
17
  def run(argv=ARGV)
18
18
  unless File.exists?(File.join(PROJECT_ROOT, 'config/appsignal.yml'))
19
19
  puts 'No config file present at config/appsignal.yml'
20
- puts 'Log in to https://appsignal.com to get instructions on how to generate the config file.'
20
+ puts 'Log in to https://appsignal.com to get instructions on how to '\
21
+ 'generate the config file.'
21
22
  exit(1)
22
23
  end
23
24
  options = {}
@@ -36,7 +37,8 @@ module Appsignal
36
37
  api_check
37
38
  end
38
39
  else
39
- puts "Command '#{command}' does not exist, run appsignal -h to see the help"
40
+ puts "Command '#{command}' does not exist, run appsignal -h to "\
41
+ "see the help"
40
42
  exit(1)
41
43
  end
42
44
  else
@@ -126,21 +128,8 @@ module Appsignal
126
128
  )
127
129
  puts "[#{env}]"
128
130
  puts ' * Configured not to monitor this environment' unless config[:active]
129
- begin
130
- result = auth_check.perform
131
- case result
132
- when '200'
133
- puts ' * AppSignal has confirmed authorisation!'
134
- when '401'
135
- puts ' * API key not valid with AppSignal...'
136
- else
137
- puts ' * Could not confirm authorisation: '\
138
- "#{result.nil? ? 'nil' : result}"
139
- end
140
- rescue Exception => e
141
- puts "Something went wrong while trying to "\
142
- "authenticate with AppSignal: #{e}"
143
- end
131
+ status, result = auth_check.perform_with_result
132
+ puts " * #{result}"
144
133
  end
145
134
  end
146
135
 
@@ -7,11 +7,11 @@ module Appsignal
7
7
  class ExceptionNotification
8
8
  attr_reader :env, :exception, :kontroller, :request, :backtrace
9
9
 
10
- def initialize(env, exception)
11
- @exception = exception
12
- @backtrace = Rails.respond_to?(:backtrace_cleaner) ?
13
- Rails.backtrace_cleaner.send(:filter, exception.backtrace) :
14
- exception.backtrace
10
+ def initialize(env, exception, rails_cleaner=true)
11
+ @exception = exception
12
+ @backtrace = rails_cleaner && Rails.respond_to?(:backtrace_cleaner) ?
13
+ Rails.backtrace_cleaner.send(:filter, exception.backtrace) :
14
+ exception.backtrace
15
15
  end
16
16
 
17
17
  def name
@@ -10,7 +10,7 @@ module Appsignal
10
10
  Appsignal::Transaction.create(env['action_dispatch.request_id'], env)
11
11
  @app.call(env)
12
12
  rescue Exception => exception
13
- unless in_ignored_exceptions?(exception)
13
+ unless Appsignal.is_ignored_exception?(exception)
14
14
  Appsignal::Transaction.current.add_exception(
15
15
  Appsignal::ExceptionNotification.new(env, exception)
16
16
  )
@@ -19,12 +19,5 @@ module Appsignal
19
19
  ensure
20
20
  Appsignal::Transaction.current.complete!
21
21
  end
22
-
23
- private
24
-
25
- def in_ignored_exceptions?(exception)
26
- Array.wrap(Appsignal.config[:ignore_exceptions]).
27
- include?(exception.class.name)
28
- end
29
22
  end
30
23
  end
@@ -125,7 +125,7 @@ module Appsignal
125
125
 
126
126
  def sanitize_session_data!
127
127
  @sanitized_session_data =
128
- Appsignal::ParamsSanitizer.sanitize(request.session)
128
+ Appsignal::ParamsSanitizer.sanitize(request.session.to_hash)
129
129
  @fullpath = request.fullpath
130
130
  end
131
131
  end
@@ -1,11 +1,15 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
3
  require 'uri'
4
- require 'json'
5
4
  require 'rack/utils'
6
5
 
7
6
  module Appsignal
8
7
  class Transmitter
8
+ CONTENT_TYPE = 'application/json; charset=UTF-8'.freeze
9
+ CONTENT_ENCODING = 'gzip'.freeze
10
+ CA_FILE_PATH = File.
11
+ expand_path(File.join(__FILE__, '../../../resources/cacert.pem'))
12
+
9
13
  attr_reader :endpoint, :action, :api_key
10
14
 
11
15
  def initialize(endpoint, action, api_key, logger=nil)
@@ -30,14 +34,12 @@ module Appsignal
30
34
 
31
35
  protected
32
36
 
33
- def ca_file_path
34
- File.expand_path(File.join(__FILE__, '../../../resources/cacert.pem'))
35
- end
36
-
37
37
  def http_post(payload)
38
- Net::HTTP::Post.new(uri.request_uri).tap do |post|
39
- post['Content-Type'] = 'application/json; charset=UTF-8'
40
- post.body = JSON.generate(payload)
38
+ Net::HTTP::Post.new(uri.request_uri).tap do |request|
39
+ request['Content-Type'] = CONTENT_TYPE
40
+ request['Content-Encoding'] = CONTENT_ENCODING
41
+ request.body = Zlib::Deflate.
42
+ deflate(Appsignal.json.encode(payload), Zlib::BEST_SPEED)
41
43
  end
42
44
  end
43
45
 
@@ -46,7 +48,7 @@ module Appsignal
46
48
  if uri.scheme == 'https'
47
49
  http.use_ssl = true
48
50
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
49
- http.ca_file = ca_file_path
51
+ http.ca_file = CA_FILE_PATH
50
52
  end
51
53
  end
52
54
  end
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.5.5'
2
+ VERSION = '0.6.0.beta.1'
3
3
  end
@@ -44,20 +44,12 @@ class AppsignalGenerator < Rails::Generators::Base
44
44
  end
45
45
 
46
46
  def check_key
47
- begin
48
- auth_check = ::Appsignal::AuthCheck.new(environment)
49
- result = auth_check.perform
50
- if result == '200'
51
- say_status :success, "AppSignal has confirmed authorisation!"
52
- elsif result == '401'
53
- say_status :error, "Push key not valid with AppSignal...", :red
54
- else
55
- say_status :error, "Could not confirm authorisation: "\
56
- "#{result.nil? ? 'nil' : result}", :red
57
- end
58
- rescue Exception => e
59
- say_status :error, "Something went wrong while trying to authenticate "\
60
- "with AppSignal: #{e}", :red
47
+ auth_check = ::Appsignal::AuthCheck.new(environment)
48
+ status, result = auth_check.perform_with_result
49
+ if status == '200'
50
+ say_status :success, result
51
+ else
52
+ say_status :error, result, :red
61
53
  end
62
54
  end
63
55
 
@@ -70,17 +62,4 @@ class AppsignalGenerator < Rails::Generators::Base
70
62
  File.join(%w(. config environments *.rb))
71
63
  ).map { |o| File.basename(o, ".rb").to_sym } - EXCLUDED_ENVIRONMENTS
72
64
  end
73
-
74
- def environment_setup?(config_file)
75
- file_contents = File.read(config_file)
76
- file_contents =~ Regexp.new("#{environment}:")
77
- end
78
-
79
- # As based on Thor's template method
80
- def new_template_content(template_file)
81
- source = File.expand_path(find_in_source_paths(template_file.to_s))
82
- context = instance_eval('binding')
83
- content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').
84
- result(context)
85
- end
86
65
  end
@@ -2,35 +2,58 @@ require 'spec_helper'
2
2
 
3
3
  describe Appsignal::AuthCheck do
4
4
  let(:auth_check) { Appsignal::AuthCheck.new('production') }
5
- before do
6
- @transmitter = mock
7
- Appsignal::Transmitter.should_receive(:new).
8
- with('http://localhost:3000/1', 'auth', 'def').
9
- and_return(@transmitter)
10
- end
11
5
 
12
- describe "#perform" do
13
- it "should not transmit any extra data" do
14
- @transmitter.should_receive(:transmit).with({}).and_return({})
15
- auth_check.perform
6
+ describe "#perform_with_result" do
7
+ it "should give success message" do
8
+ auth_check.should_receive(:perform).and_return('200')
9
+ auth_check.perform_with_result.should ==
10
+ ['200', 'AppSignal has confirmed authorisation!']
11
+ end
12
+
13
+ it "should give 401 message" do
14
+ auth_check.should_receive(:perform).and_return('401')
15
+ auth_check.perform_with_result.should ==
16
+ ['401', 'API key not valid with AppSignal...']
17
+ end
18
+
19
+ it "should give error message" do
20
+ auth_check.should_receive(:perform).and_return('402')
21
+ auth_check.perform_with_result.should ==
22
+ ['402', 'Could not confirm authorisation: 402']
16
23
  end
17
24
  end
18
25
 
19
- describe "#uri" do
26
+ context "transmitting" do
20
27
  before do
21
- @transmitter.should_receive(:transmit)
22
- auth_check.perform
28
+ @transmitter = mock
29
+ Appsignal::Transmitter.should_receive(:new).
30
+ with('http://localhost:3000/1', 'auth', 'def').
31
+ and_return(@transmitter)
23
32
  end
24
33
 
25
- it "should delegate to transmitter" do
26
- @transmitter.should_receive(:uri)
27
- auth_check.uri
34
+ describe "#perform" do
35
+ it "should not transmit any extra data" do
36
+ @transmitter.should_receive(:transmit).with({}).and_return({})
37
+ auth_check.perform
38
+ end
28
39
  end
29
40
 
30
- it "should return uri" do
31
- @transmitter.should_receive(:uri).
32
- and_return('http://appsignal.com/1/auth')
33
- auth_check.uri.should == 'http://appsignal.com/1/auth'
41
+ describe "#uri" do
42
+ before do
43
+ @transmitter.should_receive(:transmit)
44
+ auth_check.perform
45
+ end
46
+
47
+ it "should delegate to transmitter" do
48
+ @transmitter.should_receive(:uri)
49
+ auth_check.uri
50
+ end
51
+
52
+ it "should return uri" do
53
+ @transmitter.should_receive(:uri).
54
+ and_return('http://appsignal.com/1/auth')
55
+ auth_check.uri.should == 'http://appsignal.com/1/auth'
56
+ end
34
57
  end
35
58
  end
36
59
  end
@@ -5,7 +5,12 @@ describe Appsignal::CLI do
5
5
  let(:error_stream) { StringIO.new }
6
6
  let(:cli) { Appsignal::CLI }
7
7
  before :each do
8
- $stdout, $stderr = out_stream, error_stream
8
+ @original_stdout, @original_stderr = $stdout, $stderr
9
+ $stdout, $stderr = out_stream, error_stream
10
+ end
11
+ after :each do
12
+ $stdout = @original_stdout
13
+ $stderr = @original_stderr
9
14
  end
10
15
 
11
16
  describe "#logger" do
@@ -89,7 +94,7 @@ describe Appsignal::CLI do
89
94
  end
90
95
  end
91
96
 
92
- describe "api_check" do
97
+ describe "#api_check" do
93
98
  it "should detect configured environments" do
94
99
  authcheck = double
95
100
  Appsignal::AuthCheck.should_receive(:new).with(
@@ -105,8 +110,15 @@ describe Appsignal::CLI do
105
110
  kind_of(Hash)
106
111
  ).and_return(authcheck)
107
112
 
108
- authcheck.should_receive(:perform).exactly(3).times.and_return('200')
109
- cli.api_check
113
+ authcheck.should_receive(:perform_with_result).exactly(3).times.
114
+ and_return(['200', 'result'])
115
+ cli.run([
116
+ 'api_check'
117
+ ])
118
+ out_stream.string.should =~ /\[development\]/
119
+ out_stream.string.should =~ /\[production\]/
120
+ out_stream.string.should =~ /\[test\]/
121
+ out_stream.string.should =~ /\* result/
110
122
  end
111
123
  end
112
124
 
@@ -16,6 +16,7 @@ describe "Inactive Appsignal::Railtie" do
16
16
  module MyTempApp
17
17
  class Application < Rails::Application
18
18
  config.active_support.deprecation = proc { |message, stack| }
19
+ config.eager_load = false
19
20
  end
20
21
  end
21
22
  end
@@ -19,8 +19,15 @@ describe Appsignal::Railtie do
19
19
  end
20
20
 
21
21
  it "should have set the appsignal subscriber" do
22
- Appsignal.subscriber.
23
- should be_a ActiveSupport::Notifications::Fanout::Subscriber
22
+ if defined? ActiveSupport::Notifications::Fanout::Subscribers::Timed
23
+ # Rails 4
24
+ Appsignal.subscriber.
25
+ should be_a ActiveSupport::Notifications::Fanout::Subscribers::Timed
26
+ else
27
+ # Rails 3
28
+ Appsignal.subscriber.
29
+ should be_a ActiveSupport::Notifications::Fanout::Subscriber
30
+ end
24
31
  end
25
32
 
26
33
  it "should have added the listener middleware for exceptions" do
@@ -305,12 +305,12 @@ describe Appsignal::Transaction do
305
305
  subject { transaction.send(:sanitize_session_data!) }
306
306
  before do
307
307
  transaction.should respond_to(:request)
308
- transaction.stub_chain(:request, :session => :foo)
308
+ transaction.stub_chain(:request, :session => {:foo => :bar})
309
309
  transaction.stub_chain(:request, :fullpath => :bar)
310
310
  end
311
311
 
312
312
  it "passes the session data into the params sanitizer" do
313
- Appsignal::ParamsSanitizer.should_receive(:sanitize).with(:foo).
313
+ Appsignal::ParamsSanitizer.should_receive(:sanitize).with({:foo => :bar}).
314
314
  and_return(:sanitized_foo)
315
315
  subject
316
316
  transaction.sanitized_session_data.should == :sanitized_foo
@@ -319,6 +319,31 @@ describe Appsignal::Transaction do
319
319
  it "sets the fullpath of the request" do
320
320
  expect { subject }.to change(transaction, :fullpath).to(:bar)
321
321
  end
322
+
323
+ if defined? ActionDispatch::Request::Session
324
+ context "with ActionDispatch::Request::Session" do
325
+ before do
326
+ transaction.should respond_to(:request)
327
+ transaction.stub_chain(:request, :session => action_dispatch_session)
328
+ transaction.stub_chain(:request, :fullpath => :bar)
329
+ end
330
+
331
+ it "should return an session hash" do
332
+ Appsignal::ParamsSanitizer.should_receive(:sanitize).with({'foo' => :bar}).
333
+ and_return(:sanitized_foo)
334
+ subject
335
+ end
336
+
337
+
338
+ def action_dispatch_session
339
+ store = Class.new {
340
+ def load_session(env); [1, {:foo => :bar}]; end
341
+ def session_exists?(env); true; end
342
+ }.new
343
+ ActionDispatch::Request::Session.create(store, {}, {})
344
+ end
345
+ end
346
+ end
322
347
  end
323
348
  end
324
349
  end
@@ -33,7 +33,10 @@ describe Appsignal::Transmitter do
33
33
  post = mock(:post)
34
34
  post.should_receive(:[]=).
35
35
  with('Content-Type', 'application/json; charset=UTF-8')
36
- post.should_receive(:body=).with("{\"the\":\"payload\"}")
36
+ post.should_receive(:[]=).
37
+ with('Content-Encoding', 'gzip')
38
+ post.should_receive(:body=).
39
+ with(Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED))
37
40
  Socket.stub(:gethostname => 'app1.local')
38
41
 
39
42
  Net::HTTP::Post.should_receive(:new).with(
@@ -43,8 +46,8 @@ describe Appsignal::Transmitter do
43
46
  end
44
47
  end
45
48
 
46
- describe "ca_file_path" do
47
- subject { instance.send(:ca_file_path) }
49
+ describe ".CA_FILE_PATH" do
50
+ subject { Appsignal::Transmitter::CA_FILE_PATH }
48
51
 
49
52
  it { should include('resources/cacert.pem') }
50
53
  it("should exist") { File.exists?(subject).should be_true }
@@ -64,7 +67,7 @@ describe Appsignal::Transmitter do
64
67
 
65
68
  its(:use_ssl?) { should be_true }
66
69
  its(:verify_mode) { should == OpenSSL::SSL::VERIFY_PEER }
67
- its(:ca_file) { include('resources/cacert.pem') }
70
+ its(:ca_file) { Appsignal::Transmitter::CA_FILE_PATH }
68
71
  end
69
72
  end
70
73
  end
@@ -53,6 +53,12 @@ describe Appsignal do
53
53
  end
54
54
  end
55
55
 
56
+ describe ".json" do
57
+ subject { Appsignal.json }
58
+
59
+ it { should == ActiveSupport::JSON }
60
+ end
61
+
56
62
  describe ".post_processing_middleware" do
57
63
  before { Appsignal.instance_variable_set(:@post_processing_chain, nil) }
58
64
 
@@ -96,4 +102,32 @@ describe Appsignal do
96
102
  it { should be_true }
97
103
  end
98
104
  end
105
+
106
+ describe ".send_exception" do
107
+ it "should raise exception" do
108
+ agent = mock
109
+ Appsignal.should_receive(:agent).exactly(3).times.and_return(agent)
110
+ agent.should_receive(:send_queue)
111
+ agent.should_receive(:enqueue).with(kind_of(Appsignal::Transaction))
112
+
113
+ Appsignal::Transaction.should_receive(:create).and_call_original
114
+
115
+ begin
116
+ raise "I am an exception"
117
+ rescue Exception => e
118
+ Appsignal.send_exception(e)
119
+ end
120
+ end
121
+ end
122
+
123
+ describe ".listen_for_exception" do
124
+ it "should raise exception" do
125
+ Appsignal.should_receive(:send_exception).with(kind_of(Exception))
126
+ lambda {
127
+ Appsignal.listen_for_exception do
128
+ raise "I am an exception"
129
+ end
130
+ }.should raise_error(RuntimeError, "I am an exception")
131
+ end
132
+ end
99
133
  end
@@ -21,12 +21,13 @@ describe AppsignalGenerator do
21
21
  prepare_destination
22
22
  authcheck = mock()
23
23
  Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
24
- authcheck.should_receive(:perform).and_return('200')
24
+ authcheck.should_receive(:perform_with_result).
25
+ and_return(['200', 'everything ok'])
25
26
  run_generator_in_tmp %w(production my_app_key)
26
27
  end
27
28
 
28
29
  specify "should mention successful auth check" do
29
- @output.should include('AppSignal has confirmed authorisation!')
30
+ @output.should include('success everything ok')
30
31
  end
31
32
  end
32
33
 
@@ -35,12 +36,13 @@ describe AppsignalGenerator do
35
36
  prepare_destination
36
37
  authcheck = mock()
37
38
  Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
38
- authcheck.should_receive(:perform).and_return('401')
39
+ authcheck.should_receive(:perform_with_result).
40
+ and_return(['401', 'unauthorized'])
39
41
  run_generator_in_tmp %w(production my_app_key)
40
42
  end
41
43
 
42
44
  specify "should mention invalid key" do
43
- @output.should include('Push key not valid with AppSignal...')
45
+ @output.should include('error unauthorized')
44
46
  end
45
47
  end
46
48
 
@@ -49,19 +51,23 @@ describe AppsignalGenerator do
49
51
  prepare_destination
50
52
  authcheck = mock()
51
53
  Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
52
- authcheck.should_receive(:perform).and_return('500')
54
+ authcheck.should_receive(:perform_with_result).
55
+ and_return(['500', 'error!'])
53
56
  run_generator_in_tmp %w(production my_app_key)
54
57
  end
55
58
 
56
59
  specify "should mention failed check" do
57
- @output.should include('error Could not confirm authorisation: 500')
60
+ @output.should include('error error!')
58
61
  end
59
62
  end
60
63
 
61
64
  context "internal failure" do
62
65
  before do
63
66
  prepare_destination
64
- Appsignal::AuthCheck.should_receive(:new) { raise }
67
+ authcheck = Appsignal::AuthCheck.new
68
+ Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
69
+ authcheck.should_receive(:perform).
70
+ and_throw(:error)
65
71
  run_generator_in_tmp %w(production my_app_key)
66
72
  end
67
73
 
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,7 @@ end
13
13
  module MyApp
14
14
  class Application < Rails::Application
15
15
  config.active_support.deprecation = proc { |message, stack| }
16
+ config.eager_load = false
16
17
  end
17
18
  end
18
19
 
@@ -21,6 +22,7 @@ def log_file
21
22
  end
22
23
 
23
24
  require 'appsignal'
25
+ require 'appsignal/cli'
24
26
 
25
27
  RSpec.configure do |config|
26
28
  config.include TransactionHelpers
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: 0.5.5
4
+ version: 0.6.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -12,104 +12,104 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-06-09 00:00:00.000000000 Z
15
+ date: 2013-06-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ~>
21
+ - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ~>
28
+ - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3.0'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rake
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - '>='
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: json
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - '>='
49
+ - - ! '>='
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - '>='
56
+ - - ! '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - '>='
63
+ - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - '>='
70
+ - - ! '>='
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: capistrano
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>='
77
+ - - ! '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - '>='
84
+ - - ! '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: generator_spec
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - '>='
98
+ - - ! '>='
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: pry
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - '>='
105
+ - - ! '>='
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - '>='
112
+ - - ! '>='
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  description: The official appsignal.com gem
@@ -202,14 +202,14 @@ require_paths:
202
202
  - lib
203
203
  required_ruby_version: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - '>='
205
+ - - ! '>='
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  requirements:
210
- - - '>='
210
+ - - ! '>'
211
211
  - !ruby/object:Gem::Version
212
- version: '0'
212
+ version: 1.3.1
213
213
  requirements: []
214
214
  rubyforge_project:
215
215
  rubygems_version: 2.0.3