app_monit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_monit/config.rb +5 -1
- data/lib/app_monit/event.rb +1 -0
- data/lib/app_monit/version.rb +1 -1
- data/spec/app_monit/event_spec.rb +18 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f03f0553ce25ef5c665b11b1f088cfee89031a
|
4
|
+
data.tar.gz: 091ef855fe35d74590549e46af2a7077e2ab6519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa67ecdc1fad1fa70b8c9f095978400535bf05fba7aa01c71d6ea8068bea02a8784783bcf5e2cae3a4e2f7cc2fdbadfa49bc8564c2ac4f3355ac951554999a6
|
7
|
+
data.tar.gz: 81305c18b8418db8df128784bb48ecb63eb32ff0144a6e32d03a9800f006c12e0360f2a6c6096bb467e7ce3f9848c7cdb624c8aa5b1f256ed78c7b3df3f7510f
|
data/lib/app_monit/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module AppMonit
|
2
2
|
class Config
|
3
3
|
class << self
|
4
|
-
attr_writer :api_key, :env, :end_point, :fail_silent
|
4
|
+
attr_writer :api_key, :env, :end_point, :fail_silent, :enabled
|
5
5
|
|
6
6
|
def api_key
|
7
7
|
@api_key || raise(ApiKeyNotSetError.new("Please set your API key"))
|
@@ -18,6 +18,10 @@ module AppMonit
|
|
18
18
|
def fail_silent
|
19
19
|
@fail_silent || false
|
20
20
|
end
|
21
|
+
|
22
|
+
def enabled?
|
23
|
+
@enabled.nil? ? env != "test" : @enabled
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
data/lib/app_monit/event.rb
CHANGED
data/lib/app_monit/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe AppMonit::Event do
|
|
8
8
|
AppMonit::Config.api_key = 'MYAPIKEY'
|
9
9
|
AppMonit::Config.end_point = 'http://api.appmon.it'
|
10
10
|
AppMonit::Config.env = nil
|
11
|
+
AppMonit::Config.enabled = true
|
11
12
|
|
12
13
|
stub_request(:post, /.*/)
|
13
14
|
end
|
@@ -54,6 +55,20 @@ describe AppMonit::Event do
|
|
54
55
|
end
|
55
56
|
|
56
57
|
describe '#create!' do
|
58
|
+
it 'only makes request if enabled' do
|
59
|
+
AppMonit::Config.enabled = false
|
60
|
+
|
61
|
+
@mock = MiniTest::Mock.new
|
62
|
+
@mock.expect(:post, true, ['', {}])
|
63
|
+
|
64
|
+
subject.stub(:client, @mock) do
|
65
|
+
subject.create!('test', {})
|
66
|
+
assert_raises(MockExpectationError, "post should not be called") do
|
67
|
+
@mock.verify
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
57
72
|
it 'sets a created at if not given' do
|
58
73
|
@mock = MiniTest::Mock.new
|
59
74
|
@mock.expect(:post, true, ['/v1/events', { created_at: Time.at(0).utc, name: 'test', payload: {} }])
|
@@ -67,12 +82,12 @@ describe AppMonit::Event do
|
|
67
82
|
end
|
68
83
|
|
69
84
|
it 'sets calls post on http with the correct params' do
|
70
|
-
time
|
85
|
+
time = Time.now
|
71
86
|
@mock = MiniTest::Mock.new
|
72
|
-
@mock.expect(:post, true, ['/v1/events', { created_at: time.utc, name: 'test', payload: {test: 'test'} }])
|
87
|
+
@mock.expect(:post, true, ['/v1/events', { created_at: time.utc, name: 'test', payload: { test: 'test' } }])
|
73
88
|
|
74
89
|
subject.stub(:client, @mock) do
|
75
|
-
subject.create!('test', {created_at: time, test: 'test'})
|
90
|
+
subject.create!('test', { created_at: time, test: 'test' })
|
76
91
|
@mock.verify
|
77
92
|
end
|
78
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_monit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Redmar Kerkhoff
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|