status_cat 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/app/helpers/status_cat/status_helper.rb +2 -17
- data/lib/status_cat/checkers/active_record.rb +1 -8
- data/lib/status_cat/checkers/s3.rb +2 -0
- data/lib/status_cat/checkers/stripe.rb +1 -1
- data/lib/status_cat/version.rb +1 -1
- data/spec/data/report.txt +10 -10
- data/spec/data/report.txt.tmp +10 -10
- data/spec/data/status_report_format.txt +1 -1
- data/spec/data/status_report_format.txt.tmp +1 -1
- data/spec/dummy/app/checkers/dummy.rb +1 -1
- data/spec/dummy/log/development.log +343 -0
- data/spec/dummy/log/test.log +5742 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- data/spec/helpers/status_cat/status_helper_spec.rb +20 -1
- data/spec/lib/status_cat/checkers/action_mailer_spec.rb +1 -1
- data/spec/lib/status_cat/checkers/active_record_spec.rb +4 -8
- data/spec/lib/status_cat/checkers/base_spec.rb +2 -2
- data/spec/lib/status_cat/checkers/delayed_job_spec.rb +26 -1
- data/spec/lib/status_cat/checkers/s3_spec.rb +26 -2
- data/spec/lib/status_cat/checkers/stripe_spec.rb +31 -2
- data/spec/lib/status_cat/config_spec.rb +1 -1
- data/spec/lib/status_cat/status_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- metadata +103 -3
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
58006
|
@@ -33,6 +33,20 @@ describe StatusCat::StatusHelper do
|
|
33
33
|
|
34
34
|
end
|
35
35
|
|
36
|
+
describe '#status_cell' do
|
37
|
+
|
38
|
+
it 'returns the status as a table cell' do
|
39
|
+
expected = "<td>foo</td>"
|
40
|
+
expect( helper.status_cell( 'foo' ) ).to eql( expected )
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'converts array statuses into html lists' do
|
44
|
+
expected = "<td><ul><li>foo</li><li>bar</li></ul></td>"
|
45
|
+
expect( helper.status_cell( [ 'foo', 'bar' ] ) ).to eql( expected )
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
36
50
|
describe '#status_style' do
|
37
51
|
|
38
52
|
it 'returns a green background when the status is nil' do
|
@@ -69,6 +83,8 @@ describe StatusCat::StatusHelper do
|
|
69
83
|
|
70
84
|
it 'generates a text status report' do
|
71
85
|
all = StatusCat::Status.all
|
86
|
+
all.each { |s| s.stub( :status ).and_return( nil ) }
|
87
|
+
|
72
88
|
helper.status_report( all ).should eql_file( 'spec/data/report.txt' )
|
73
89
|
end
|
74
90
|
|
@@ -77,7 +93,10 @@ describe StatusCat::StatusHelper do
|
|
77
93
|
describe '#status_report_format' do
|
78
94
|
|
79
95
|
it 'generates a format string and length based on the max length of the given checkers' do
|
80
|
-
|
96
|
+
all = StatusCat::Status.all
|
97
|
+
all.each { |s| s.stub( :status ).and_return( nil ) }
|
98
|
+
|
99
|
+
status_report_format = helper.status_report_format( all ).to_s
|
81
100
|
status_report_format.should eql_file( 'spec/data/status_report_format.txt' )
|
82
101
|
end
|
83
102
|
|
@@ -59,7 +59,7 @@ describe StatusCat::Checkers::ActionMailer do
|
|
59
59
|
|
60
60
|
it 'returns an error message if it can not send a message' do
|
61
61
|
smtp = Object.new
|
62
|
-
smtp.stub
|
62
|
+
smtp.stub( :send_message ).and_raise( exception )
|
63
63
|
Net::SMTP.should_receive( :start ).and_yield( smtp )
|
64
64
|
checker = StatusCat::Checkers::ActionMailer.new
|
65
65
|
checker.status.should be( exception )
|
@@ -6,14 +6,10 @@ describe StatusCat::Checkers::ActiveRecord do
|
|
6
6
|
|
7
7
|
it_should_behave_like 'a status checker'
|
8
8
|
|
9
|
-
it 'provides configuration' do
|
10
|
-
yaml = YAML::load( ERB.new( IO.read( File.join( Rails.root, 'config', 'database.yml' ) ) ).result )
|
11
|
-
expected = yaml[ Rails.env ].symbolize_keys!
|
12
|
-
checker.config.should eql( expected )
|
13
|
-
end
|
14
|
-
|
15
9
|
it 'constructs a value from the configuration' do
|
16
|
-
|
10
|
+
config = { :adapter => 'postgres', :username => 'dba', :database => 'test' }
|
11
|
+
expect( ::ActiveRecord::Base ).to receive( :connection_config ).and_return( config )
|
12
|
+
expected = "#{config[ :adapter ]}:#{config[ :username ]}@#{config[ :database ]}"
|
17
13
|
checker.value.should eql( expected )
|
18
14
|
end
|
19
15
|
|
@@ -22,7 +18,7 @@ describe StatusCat::Checkers::ActiveRecord do
|
|
22
18
|
context 'pass' do
|
23
19
|
|
24
20
|
it 'passes if it can execute a query against the database' do
|
25
|
-
ActiveRecord::Base.connection.stub
|
21
|
+
ActiveRecord::Base.connection.stub( :execute )
|
26
22
|
checker = StatusCat::Checkers::ActiveRecord.new
|
27
23
|
checker.status.should be_nil
|
28
24
|
end
|
@@ -24,8 +24,8 @@ describe StatusCat::Checkers::Base do
|
|
24
24
|
describe '#to_s' do
|
25
25
|
|
26
26
|
before( :each ) do
|
27
|
-
checker.stub
|
28
|
-
checker.stub
|
27
|
+
checker.stub( :value ).and_return( 'secret' )
|
28
|
+
checker.stub( :status ).and_return( 'fail' )
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'generates a string' do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'delayed_job_active_record'
|
2
3
|
|
3
4
|
describe StatusCat::Checkers::DelayedJob do
|
4
5
|
|
@@ -10,6 +11,30 @@ describe StatusCat::Checkers::DelayedJob do
|
|
10
11
|
|
11
12
|
it_should_behave_like 'a status checker'
|
12
13
|
|
13
|
-
it '
|
14
|
+
it 'tolerates Delayed::Job being undefined' do
|
15
|
+
dj = Object.send(:remove_const, :Delayed)
|
16
|
+
expect( checker.status ).to_not be_nil
|
17
|
+
Object.const_set( :Delayed, dj )
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'fails if there is an exception' do
|
21
|
+
ActiveRecord::Base.connection.should_receive( :execute ).and_raise( :error )
|
22
|
+
expect( checker.status ).to_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'fails if there are expired jobs' do
|
26
|
+
ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [1] )
|
27
|
+
expect( checker.status ).to_not be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'passes if there are no expired jobs' do
|
31
|
+
ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [0] )
|
32
|
+
expect( checker.status ).to be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'uses the job count as the value' do
|
36
|
+
ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [0] )
|
37
|
+
expect( checker.value ).to eql( 1 )
|
38
|
+
end
|
14
39
|
|
15
40
|
end
|
@@ -1,15 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'aws-sdk'
|
2
3
|
|
3
4
|
describe StatusCat::Checkers::S3 do
|
4
5
|
|
5
6
|
let( :checker ) { StatusCat::Checkers::S3.new.freeze }
|
6
7
|
|
7
8
|
before( :each ) do
|
8
|
-
|
9
|
+
AWS::S3.stub( :new ).and_return( @s3 = double( AWS::S3 ) )
|
9
10
|
end
|
10
11
|
|
11
12
|
it_should_behave_like 'a status checker'
|
12
13
|
|
13
|
-
it '
|
14
|
+
it 'tolerates AWS being undefined' do
|
15
|
+
aws = Object.send(:remove_const, :AWS)
|
16
|
+
expect( checker.status ).to_not be_nil
|
17
|
+
Object.const_set( :AWS, aws )
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'uses the aws access key as the value' do
|
21
|
+
expect( checker.value ).to eql( AWS.config.access_key_id )
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'fails if there is an exception talking to S3' do
|
25
|
+
expect( @s3 ).to receive( :buckets ).and_raise( 'error' )
|
26
|
+
expect( checker.status ).to_not be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'fails if there are no S3 buckets' do
|
30
|
+
expect( @s3 ).to receive( :buckets ).and_return( [] )
|
31
|
+
expect( checker.status ).to_not be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'passes if it finds S3 buckets' do
|
35
|
+
expect( @s3 ).to receive( :buckets ).and_return( [ 1 ] )
|
36
|
+
expect( checker.status ).to be_nil
|
37
|
+
end
|
14
38
|
|
15
39
|
end
|
@@ -1,15 +1,44 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'stripe'
|
2
3
|
|
3
4
|
describe StatusCat::Checkers::Stripe do
|
4
5
|
|
5
6
|
let( :checker ) { StatusCat::Checkers::Stripe.new.freeze }
|
7
|
+
let( :email ) { 'foo@bar.com' }
|
6
8
|
|
7
9
|
before( :each ) do
|
8
|
-
|
10
|
+
Stripe::Account.stub( :retrieve ).and_return( @stripe = double( Stripe::Account ) )
|
9
11
|
end
|
10
12
|
|
11
13
|
it_should_behave_like 'a status checker'
|
12
14
|
|
13
|
-
it '
|
15
|
+
it 'tolerates Stripe being undefined' do
|
16
|
+
stripe = Object.send(:remove_const, :Stripe)
|
17
|
+
expect( checker.status ).to_not be_nil
|
18
|
+
Object.const_set( :Stripe, stripe )
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'fails if there is an exception talking to Stripe' do
|
22
|
+
expect( @stripe ).to receive( :email ).and_raise( 'error' )
|
23
|
+
expect( checker.status ).to_not be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'fails if charging is not enabled' do
|
27
|
+
expect( @stripe ).to receive( :charge_enabled ).and_return( false )
|
28
|
+
expect( @stripe ).to receive( :email ).and_return( email )
|
29
|
+
expect( checker.status ).to_not be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'passes if charging is enabled' do
|
33
|
+
expect( @stripe ).to receive( :charge_enabled ).and_return( true )
|
34
|
+
expect( @stripe ).to receive( :email ).and_return( email )
|
35
|
+
expect( checker.status ).to be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'uses the account email as the value' do
|
39
|
+
expect( @stripe ).to receive( :charge_enabled ).and_return( true )
|
40
|
+
expect( @stripe ).to receive( :email ).and_return( email )
|
41
|
+
expect( checker.value ).to eql( email )
|
42
|
+
end
|
14
43
|
|
15
44
|
end
|
@@ -17,7 +17,7 @@ describe StatusCat::Config do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'has an #authorize accessor' do
|
20
|
-
config.authorize
|
20
|
+
config.authorize = StatusCat::Config::NIL_PROC
|
21
21
|
config.authorize = config.authorize
|
22
22
|
config.authorize.should eql( config.authorize )
|
23
23
|
end
|
@@ -101,7 +101,7 @@ describe StatusCat::Status do
|
|
101
101
|
@pass = StatusCat::Checkers::Base.new
|
102
102
|
|
103
103
|
@fail = StatusCat::Checkers::Base.new
|
104
|
-
@fail.stub
|
104
|
+
@fail.stub( :status ).and_return( :fail )
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'returns only failed checkers from ::all' do
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
ENV['RAILS_ENV'] ||= 'test'
|
3
3
|
|
4
4
|
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
5
11
|
|
6
12
|
SimpleCov.start 'rails' do
|
7
13
|
add_filter '/vendor/'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: status_cat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Humphrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -110,6 +110,106 @@ dependencies:
|
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 0.7.3
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: simplecov
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0.8'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.8.2
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.8'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 0.8.2
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: coveralls
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.7'
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.7.0
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0.7'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.7.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: spec_cat
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.1'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.1.0
|
163
|
+
type: :development
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0.1'
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 0.1.0
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: aws-sdk
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0.38'
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 0.38.0
|
183
|
+
type: :development
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0.38'
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 0.38.0
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: delayed_job_active_record
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - "~>"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '4.0'
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 4.0.0
|
203
|
+
type: :development
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '4.0'
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: 4.0.0
|
113
213
|
description: |2
|
114
214
|
This engine makes monitoring the status of your Rails environment easier.
|
115
215
|
|
@@ -269,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
369
|
version: '0'
|
270
370
|
requirements: []
|
271
371
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.2.
|
372
|
+
rubygems_version: 2.2.2
|
273
373
|
signing_key:
|
274
374
|
specification_version: 4
|
275
375
|
summary: A Rails engine for checking system health
|