rnotifier 0.1.3 → 0.1.4

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: 230323fb6bf53cf96bb51c161db128e700ee4418
4
- data.tar.gz: 1d6ae42ba52711eb1dcf22f276d8ba6f1c08b83f
3
+ metadata.gz: cef52d8a3834d6330dac03da18ad5818b39d4827
4
+ data.tar.gz: 8f43aefa2e62a789143777ef5611159913492f93
5
5
  SHA512:
6
- metadata.gz: 689155f28d570e40a98551e59b23e5837c82dd9a6fd85c67df1f383d60fc78a8c3e0fb315ab328d2bf350e64cb5516c2fc9ef47837b15b7f92898ee2fbed3260
7
- data.tar.gz: e0ca66d1a5c13467fc94f2fe3effb39aa67095d6fb7b185ce2ea8ec9f66c1d6c4d13cc57aadd05cbd40bc3aef693583d99f68b3e39f8bf46cd2848b3d2b1399c
6
+ metadata.gz: 469d40fde0290c0358022b086a3090c7e27d1096cc016a83691ec6f87cdf827695539d8ace509ea5e204caaf80a84373b71f3fe540f0c86db2ab75ae464e4c79
7
+ data.tar.gz: 73f0251a3f9b57930b637e14f9bff14e4db7a6d36f4b3e71ccef4b32a3dd07f1ef0b8d6f918e03882a3d40e47798a9f3b0d7fecccf5740b559d57605cf91649e
data/.gitignore CHANGED
@@ -17,3 +17,5 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  log
20
+ config/
21
+ *.diff
data/bin/rnotifier CHANGED
@@ -17,6 +17,8 @@ install api-key [environments] #Create config/rnotifier.yaml with api_key and en
17
17
  require 'rnotifier/config_test.rb'
18
18
  ENV['RACK_ENV'] = 'rnotifier_test'
19
19
  Rnotifier.load_config('config/rnotifier.yaml')
20
+ Rnotifier::Config.environments = [ENV['RACK_ENV']]
21
+ Rnotifier::Config.init
20
22
  if Rnotifier::Config.valid?
21
23
  Rnotifier::ConfigTest.test
22
24
  else
@@ -7,11 +7,12 @@ module Rnotifier
7
7
  begin
8
8
  raise TestException.new('Test exception')
9
9
  rescue Exception => e
10
- if Rnotifier::ExceptionData.new(e, {}).notify
11
- puts "Test Exception sent. Login to rnotifier.com and checkout."
10
+ if status = Rnotifier.exception(e, {})
11
+ puts "Test Exception sent. Login to www.rnotifier.com and checkout."
12
12
  else
13
- puts "Problem sending exception to rnotifier.com. Check your API key or config."
13
+ puts "Problem sending exception to www.rnotifier.com. Check your API key or config."
14
14
  end
15
+ status
15
16
  end
16
17
  end
17
18
 
@@ -16,7 +16,7 @@ module Rnotifier
16
16
  end
17
17
  end
18
18
 
19
- filename, line, method = (bline|| backtrace[0]).split(':')
19
+ filename, line, method = (bline || exception.backtrace[0]).split(':')
20
20
 
21
21
  self.find(filename, line.to_i, 3)
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Rnotifier
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,36 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe Rnotifier::ConfigTest do
5
+
6
+ after(:each) do
7
+ ENV['RACK_ENV'] = 'test'
8
+ end
9
+
10
+ it 'sends test exception exception' do
11
+ rnotifier_init
12
+ stubs = stub_faraday_request
13
+
14
+ expect(Rnotifier::ConfigTest.test).to be_true
15
+ expect(Rnotifier::Config.api_key).to eq 'API-KEY'
16
+ expect {stubs.verify_stubbed_calls }.to_not raise_error
17
+ end
18
+
19
+ it 'sends test exception for rnotifier_test env' do
20
+
21
+ ['rnotifier_without_env', 'rnotifier'].each do |c|
22
+ stubs = stub_faraday_request
23
+
24
+ ENV['RACK_ENV'] = 'rnotifier_test'
25
+ Rnotifier.load_config("#{Dir.pwd}/spec/fixtures/#{c}.yaml")
26
+ Rnotifier::Config.environments = [ENV['RACK_ENV']]
27
+ Rnotifier::Config.init
28
+
29
+ expect(Rnotifier::Config.valid?).to be_true
30
+ expect(Rnotifier::Config.api_key).to eq 'API-KEY'
31
+ expect(Rnotifier::ConfigTest.test).to be_true
32
+ expect {stubs.verify_stubbed_calls }.to_not raise_error
33
+ end
34
+ end
35
+
36
+ end
@@ -63,4 +63,28 @@ describe Rnotifier::ExceptionCode do
63
63
  expect(code).to eq([6].concat(lines))
64
64
  end
65
65
 
66
+ it 'return nil if backtrace is nil' do
67
+ rnotifier_init
68
+
69
+ e = Exception.new('No backtrace')
70
+ code = Rnotifier::ExceptionCode.get(e)
71
+
72
+ expect(code).to be_nil
73
+ end
74
+
75
+ it 'return first line of backtrace if exception not a systax error or not rails form app' do
76
+ rnotifier_init
77
+ Rnotifier::Config.app_env[:app_root] = '/noroot'
78
+
79
+ e = Exception.new('Non app exception')
80
+ e.set_backtrace([File.dirname(__FILE__) + "/mock_exception_helper.rb:3:in `mock_exception'"])
81
+
82
+ code = Rnotifier::ExceptionCode.get(e)
83
+ lines = File.readlines(File.dirname(__FILE__) + "/mock_exception_helper.rb")[0..5]
84
+
85
+ expect(code).to eq([0].concat(lines))
86
+ rnotifier_init
87
+ end
88
+
89
+
66
90
  end
@@ -0,0 +1 @@
1
+ apikey: API-KEY
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,7 @@ Coveralls.wear!
20
20
  $:.unshift(File.dirname(__FILE__) + '/../lib/')
21
21
 
22
22
  require 'rnotifier'
23
+ require 'rnotifier/config_test'
23
24
  require File.dirname(__FILE__) + '/mock_exception_helper'
24
25
  require File.dirname(__FILE__) + '/fixtures/test_sinatra_app'
25
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnotifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiren Patel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -139,6 +139,7 @@ files:
139
139
  - lib/rnotifier/version.rb
140
140
  - rnotifier.gemspec
141
141
  - spec/config_spec.rb
142
+ - spec/config_test_spec.rb
142
143
  - spec/event_data_spec.rb
143
144
  - spec/exception_code_spec.rb
144
145
  - spec/exception_data_spec.rb
@@ -146,6 +147,7 @@ files:
146
147
  - spec/fixtures/rnotifier.yaml
147
148
  - spec/fixtures/rnotifier_ignore_env.yaml
148
149
  - spec/fixtures/rnotifier_test.yaml
150
+ - spec/fixtures/rnotifier_without_env.yaml
149
151
  - spec/fixtures/test_sinatra_app.rb
150
152
  - spec/mock_exception_helper.rb
151
153
  - spec/rack_middleware_spec.rb
@@ -176,6 +178,7 @@ specification_version: 4
176
178
  summary: Exception catcher for Rails and other Rack apps
177
179
  test_files:
178
180
  - spec/config_spec.rb
181
+ - spec/config_test_spec.rb
179
182
  - spec/event_data_spec.rb
180
183
  - spec/exception_code_spec.rb
181
184
  - spec/exception_data_spec.rb
@@ -183,6 +186,7 @@ test_files:
183
186
  - spec/fixtures/rnotifier.yaml
184
187
  - spec/fixtures/rnotifier_ignore_env.yaml
185
188
  - spec/fixtures/rnotifier_test.yaml
189
+ - spec/fixtures/rnotifier_without_env.yaml
186
190
  - spec/fixtures/test_sinatra_app.rb
187
191
  - spec/mock_exception_helper.rb
188
192
  - spec/rack_middleware_spec.rb