status_cat 0.1.0 → 0.1.1
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 +26 -20
- data/lib/status_cat/checkers/delayed_job.rb +2 -2
- data/lib/status_cat/checkers/fitbit.rb +20 -0
- data/lib/status_cat/checkers/profilesio.rb +13 -0
- data/lib/status_cat/checkers/send_hub.rb +13 -0
- data/lib/status_cat/checkers/twilio.rb +13 -0
- data/lib/status_cat/status.rb +1 -1
- data/lib/status_cat/version.rb +1 -1
- data/lib/status_cat.rb +4 -0
- data/spec/controllers/status_cat/status_controller_spec.rb +8 -10
- data/spec/coverage_spec.rb +1 -3
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -1232
- data/spec/dummy/log/test.log +12344 -6383
- data/spec/helpers/status_cat/status_helper_spec.rb +17 -28
- data/spec/lib/status_cat/checkers/action_mailer_spec.rb +9 -15
- data/spec/lib/status_cat/checkers/active_record_spec.rb +5 -11
- data/spec/lib/status_cat/checkers/base_spec.rb +9 -16
- data/spec/lib/status_cat/checkers/delayed_job_spec.rb +4 -10
- data/spec/lib/status_cat/checkers/fitbit_spec.rb +33 -0
- data/spec/lib/status_cat/checkers/profilesio_spec.rb +38 -0
- data/spec/lib/status_cat/checkers/s3_spec.rb +1 -3
- data/spec/lib/status_cat/checkers/send_hub_spec.rb +33 -0
- data/spec/lib/status_cat/checkers/stripe_spec.rb +1 -3
- data/spec/lib/status_cat/checkers/twilio_spec.rb +33 -0
- data/spec/lib/status_cat/config_spec.rb +36 -29
- data/spec/lib/status_cat/engine_spec.rb +1 -4
- data/spec/lib/status_cat/status_spec.rb +19 -27
- data/spec/lib/status_cat/version_spec.rb +3 -6
- data/spec/lib/status_cat_spec.rb +2 -7
- data/spec/lib/tasks/status_cat.rake_spec.rb +2 -7
- data/spec/mailers/status_cat/status_mailer_spec.rb +9 -13
- data/spec/spec_helper.rb +21 -1
- data/spec/support/shared/checker.rb +4 -6
- data/spec/views/status_cat/status/index.html.erb_spec.rb +3 -5
- data/spec/views/status_cat/status_mailer/failure.html.erb_spec.rb +1 -3
- data/spec/views/status_cat/status_mailer/failure.text.erb_spec.rb +1 -4
- metadata +107 -41
- data/spec/data/report.txt +0 -10
- data/spec/data/report.txt.tmp +0 -10
- data/spec/data/status_report_format.txt +0 -1
- data/spec/data/status_report_format.txt.tmp +0 -1
- data/spec/dummy/config/passwords.yml +0 -5
- data/spec/dummy/db/production.sqlite3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0891c389c9f47b48b695b65602d93a57 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/400d7aa6ca317151fe36fc9f02ccfc4e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/40da66d7323888023264d2f06b7525d4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4bddf542ba5114155847240380cf6e7c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/572759e0267736e8961ff1fad85cfe47 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6cec2a8a17b78e61daecff44044e1179 +0 -0
- data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe StatusCat::Status do
|
4
2
|
|
5
3
|
#############################################################################
|
@@ -10,14 +8,13 @@ describe StatusCat::Status do
|
|
10
8
|
|
11
9
|
it 'returns an array of enabled checkers' do
|
12
10
|
enabled = StatusCat::Config.instance.enabled
|
13
|
-
StatusCat::Config.instance.
|
11
|
+
expect( StatusCat::Config.instance ).to receive( :enabled ).and_return( enabled )
|
14
12
|
|
15
13
|
all = StatusCat::Status.all
|
16
|
-
all.
|
17
|
-
all.length.
|
18
|
-
all.each { |checker| checker.
|
14
|
+
expect( all ).to be_an_instance_of( Array )
|
15
|
+
expect( all.length ).to eql( StatusCat::Checkers::Base.descendants.length )
|
16
|
+
all.each { |checker| expect( checker ).to be_a_kind_of( StatusCat::Checkers::Base ) }
|
19
17
|
end
|
20
|
-
|
21
18
|
end
|
22
19
|
|
23
20
|
#############################################################################
|
@@ -27,9 +24,9 @@ describe StatusCat::Status do
|
|
27
24
|
describe '::check' do
|
28
25
|
|
29
26
|
def checker_array_should_have_names( actual, expected )
|
30
|
-
actual.
|
31
|
-
actual.length.
|
32
|
-
actual.each_index { |i| actual[ i ].name.
|
27
|
+
expect( actual ).to be_a_kind_of( Array )
|
28
|
+
expect( actual.length ).to eql( expected.length )
|
29
|
+
actual.each_index { |i| expect( actual[ i ].name ).to be( expected[ i ] ) }
|
33
30
|
end
|
34
31
|
|
35
32
|
it 'defaults to all checkers' do
|
@@ -45,7 +42,7 @@ describe StatusCat::Status do
|
|
45
42
|
end
|
46
43
|
|
47
44
|
it 'returns a single checker when given a single symbolic name' do
|
48
|
-
StatusCat::Status.check( :active_record ).
|
45
|
+
expect( StatusCat::Status.check( :active_record ) ).to be_an_instance_of( StatusCat::Checkers::ActiveRecord )
|
49
46
|
end
|
50
47
|
|
51
48
|
it 'returns an array of checkers when given an array of symbolic name' do
|
@@ -53,7 +50,6 @@ describe StatusCat::Status do
|
|
53
50
|
checkers = StatusCat::Status.check( names )
|
54
51
|
checker_array_should_have_names( checkers, names )
|
55
52
|
end
|
56
|
-
|
57
53
|
end
|
58
54
|
|
59
55
|
#############################################################################
|
@@ -65,17 +61,16 @@ describe StatusCat::Status do
|
|
65
61
|
it 'delivers email if ::failed is not empty' do
|
66
62
|
failed = [ StatusCat::Checkers::Base.new ]
|
67
63
|
mail = StatusCat::StatusMailer.failure( failed )
|
68
|
-
StatusCat::Status.
|
69
|
-
StatusCat::StatusMailer.
|
64
|
+
expect( StatusCat::Status ).to receive( :failed ).and_return( failed )
|
65
|
+
expect( StatusCat::StatusMailer ).to receive( :failure ).with( failed ).and_return( mail )
|
70
66
|
StatusCat::Status.cron
|
71
67
|
end
|
72
68
|
|
73
69
|
it 'does not email when ::failed is empty' do
|
74
|
-
StatusCat::Status.
|
75
|
-
StatusCat::StatusMailer.
|
70
|
+
expect( StatusCat::Status ).to receive( :failed ).and_return( [] )
|
71
|
+
expect( StatusCat::StatusMailer ).to_not receive( :failure )
|
76
72
|
StatusCat::Status.cron
|
77
73
|
end
|
78
|
-
|
79
74
|
end
|
80
75
|
|
81
76
|
#############################################################################
|
@@ -85,10 +80,9 @@ describe StatusCat::Status do
|
|
85
80
|
describe '::factory' do
|
86
81
|
|
87
82
|
it 'constructs a checker given its symbolic name' do
|
88
|
-
StatusCat::Status.factory( :action_mailer ).
|
89
|
-
StatusCat::Status.factory( :active_record ).
|
83
|
+
expect( StatusCat::Status.factory( :action_mailer ) ).to be_an_instance_of( StatusCat::Checkers::ActionMailer )
|
84
|
+
expect( StatusCat::Status.factory( :active_record ) ).to be_an_instance_of( StatusCat::Checkers::ActiveRecord )
|
90
85
|
end
|
91
|
-
|
92
86
|
end
|
93
87
|
|
94
88
|
#############################################################################
|
@@ -101,20 +95,18 @@ describe StatusCat::Status do
|
|
101
95
|
@pass = StatusCat::Checkers::Base.new
|
102
96
|
|
103
97
|
@fail = StatusCat::Checkers::Base.new
|
104
|
-
@fail.
|
98
|
+
allow( @fail ).to receive( :status ).and_return( :fail )
|
105
99
|
end
|
106
100
|
|
107
101
|
it 'returns only failed checkers from ::all' do
|
108
|
-
StatusCat::Status.
|
109
|
-
StatusCat::Status.failed.
|
102
|
+
expect( StatusCat::Status ).to receive( :all ).and_return( [ @pass, @fail ] )
|
103
|
+
expect( StatusCat::Status.failed ).to eql( [ @fail ] )
|
110
104
|
end
|
111
105
|
|
112
106
|
it 'returns an empty list if all checkers pass' do
|
113
|
-
StatusCat::Status.
|
114
|
-
StatusCat::Status.failed.
|
107
|
+
expect( StatusCat::Status ).to receive( :all ).and_return( [ @pass ] )
|
108
|
+
expect( StatusCat::Status.failed ).to eql( [] )
|
115
109
|
end
|
116
|
-
|
117
110
|
end
|
118
|
-
|
119
111
|
end
|
120
112
|
|
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe 'version' do
|
4
2
|
|
5
3
|
it 'has a version constant' do
|
6
|
-
StatusCat::VERSION.
|
7
|
-
StatusCat::VERSION.
|
8
|
-
StatusCat::VERSION.
|
4
|
+
expect( StatusCat::VERSION ).to_not be_nil
|
5
|
+
expect( StatusCat::VERSION ).to be_an_instance_of( String )
|
6
|
+
expect( StatusCat::VERSION ).to match( /\d+\.\d+\.\d+/ )
|
9
7
|
end
|
10
|
-
|
11
8
|
end
|
data/spec/lib/status_cat_spec.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe StatusCat do
|
4
2
|
|
5
3
|
describe '::config' do
|
6
4
|
|
7
5
|
it 'returns the configuration' do
|
8
|
-
StatusCat.config.
|
6
|
+
expect( StatusCat.config ).to be( StatusCat::Config.instance )
|
9
7
|
end
|
10
|
-
|
11
8
|
end
|
12
9
|
|
13
10
|
describe '::configure' do
|
14
11
|
|
15
12
|
it 'yields the configuration' do
|
16
|
-
StatusCat.configure { |config| config.
|
13
|
+
StatusCat.configure { |config| expect( config ).to be( StatusCat::Config.instance ) }
|
17
14
|
end
|
18
|
-
|
19
15
|
end
|
20
|
-
|
21
16
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
1
|
require 'rake'
|
3
2
|
|
4
3
|
describe 'status_cat rake tasks' do
|
@@ -13,20 +12,16 @@ describe 'status_cat rake tasks' do
|
|
13
12
|
describe 'rake status_cat:check' do
|
14
13
|
|
15
14
|
it 'puts the status report' do
|
16
|
-
Kernel.
|
15
|
+
expect( Kernel ).to receive( :puts ).with( kind_of( String ) )
|
17
16
|
@rake[ 'status_cat:check' ].invoke
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
21
19
|
|
22
20
|
describe 'rake status_cat:cron' do
|
23
21
|
|
24
22
|
it 'calls StatusCat::Status.cron' do
|
25
|
-
StatusCat::Status.
|
23
|
+
expect( StatusCat::Status ).to receive( :cron )
|
26
24
|
@rake[ 'status_cat:cron' ].invoke
|
27
25
|
end
|
28
|
-
|
29
26
|
end
|
30
|
-
|
31
|
-
|
32
27
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe StatusCat::StatusMailer do
|
4
2
|
|
5
3
|
it 'adds StatusCat::StatusHelper as a template helper' do
|
6
4
|
modules = StatusCat::StatusMailer._helpers.included_modules
|
7
|
-
modules.
|
5
|
+
expect( modules ).to include( StatusCat::StatusHelper )
|
8
6
|
end
|
9
7
|
|
10
8
|
describe '#failure' do
|
@@ -13,26 +11,24 @@ describe StatusCat::StatusMailer do
|
|
13
11
|
let( :config ) { StatusCat.config }
|
14
12
|
|
15
13
|
it 'uses the configured from address' do
|
16
|
-
mail.from.
|
17
|
-
mail.from.
|
14
|
+
expect( mail.from ).to_not be_nil
|
15
|
+
expect( mail.from ).to eql( [ config.from ] )
|
18
16
|
end
|
19
17
|
|
20
18
|
it 'uses the configured to address' do
|
21
|
-
mail.to.
|
22
|
-
mail.to.
|
19
|
+
expect( mail.to ).to_not be_nil
|
20
|
+
expect( mail.to ).to eql( [ config.to ] )
|
23
21
|
end
|
24
22
|
|
25
23
|
it 'uses the configured subject' do
|
26
|
-
mail.subject.
|
27
|
-
mail.subject.
|
24
|
+
expect( mail.subject ).to_not be_nil
|
25
|
+
expect( mail.subject ).to eql( config.subject )
|
28
26
|
end
|
29
27
|
|
30
28
|
it 'generates a multipart email with both text and html' do
|
31
|
-
mail.parts.first.content_type.
|
32
|
-
mail.parts.second.content_type.
|
29
|
+
expect( mail.parts.first.content_type ).to eql( 'text/plain; charset=UTF-8' )
|
30
|
+
expect( mail.parts.second.content_type ).to eql( 'text/html; charset=UTF-8' )
|
33
31
|
end
|
34
|
-
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
38
34
|
|
data/spec/spec_helper.rb
CHANGED
@@ -16,10 +16,14 @@ end
|
|
16
16
|
|
17
17
|
require File.expand_path('../dummy/config/environment', __FILE__)
|
18
18
|
require 'rspec/rails'
|
19
|
-
require 'rspec/autorun'
|
20
19
|
|
21
20
|
require 'spec_cat'
|
22
21
|
|
22
|
+
require 'fitgem'
|
23
|
+
require 'httparty'
|
24
|
+
require 'ruby-sendhub'
|
25
|
+
require 'twilio-ruby'
|
26
|
+
|
23
27
|
ENGINE_ROOT = File.join(File.dirname(__FILE__), '..')
|
24
28
|
|
25
29
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
@@ -47,10 +51,26 @@ RSpec.configure do |config|
|
|
47
51
|
# automatically. This will be the default behavior in future versions of
|
48
52
|
# rspec-rails.
|
49
53
|
config.infer_base_class_for_anonymous_controllers = false
|
54
|
+
config.infer_spec_type_from_file_location!
|
50
55
|
|
51
56
|
# Run specs in random order to surface order dependencies. If you find an
|
52
57
|
# order dependency and want to debug it, you can fix the order by providing
|
53
58
|
# the seed, which is printed after each run.
|
54
59
|
# --seed 1234
|
55
60
|
config.order = 'random'
|
61
|
+
|
62
|
+
config.before( :each ) do
|
63
|
+
allow( Fitgem::Client ).to receive( :new ).and_return( @fitgem = double( Fitgem::Client ) )
|
64
|
+
allow( @fitgem ).to receive( :user_info ).and_return( {} )
|
65
|
+
|
66
|
+
allow( HTTParty ).to receive( :get ).and_return( double( "response", :code => 200 ) )
|
67
|
+
|
68
|
+
allow( SendHub ).to receive( :new ).and_return( @send_hub = double( SendHub ) )
|
69
|
+
allow( @send_hub ).to receive( :get_contacts ).and_return( {} )
|
70
|
+
|
71
|
+
allow( Twilio::REST::Client ).to receive( :new ).and_return( @twilio = double( Twilio::REST::Client ) )
|
72
|
+
allow( @twilio ).to receive( :account ).and_return( @twilio_account = double( Twilio::REST::Account ) )
|
73
|
+
allow( @twilio_account ).to receive( :messages ).and_return( @twilio_messages = double( Twilio::REST::Messages ) )
|
74
|
+
allow( @twilio_messages ).to receive( :total ).and_return( 0 )
|
75
|
+
end
|
56
76
|
end
|
@@ -1,25 +1,23 @@
|
|
1
1
|
shared_examples_for 'a status checker' do
|
2
2
|
|
3
3
|
it 'inherits from StatusCat::Checker' do
|
4
|
-
checker.
|
4
|
+
expect( checker ).to be_a_kind_of( StatusCat::Checkers::Base )
|
5
5
|
end
|
6
6
|
|
7
7
|
describe 'attributes' do
|
8
8
|
|
9
9
|
it 'has a name reader' do
|
10
10
|
expected = checker.class.to_s.split( '::' ).last.underscore.to_sym
|
11
|
-
checker.name.
|
11
|
+
expect( checker.name ).to eql( expected )
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has a value reader' do
|
15
|
-
checker.value.
|
15
|
+
expect( checker.value ).to eql( checker.value )
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'has a status reader' do
|
19
|
-
checker.status.
|
19
|
+
expect( checker.status ).to eql( checker.status )
|
20
20
|
end
|
21
|
-
|
22
21
|
end
|
23
|
-
|
24
22
|
end
|
25
23
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe 'status_cat/status/index.html.erb' do
|
4
2
|
|
5
3
|
before( :each ) do
|
@@ -9,16 +7,16 @@ describe 'status_cat/status/index.html.erb' do
|
|
9
7
|
|
10
8
|
it 'includes an h1 tag' do
|
11
9
|
render
|
12
|
-
rendered.
|
10
|
+
expect( rendered ).to match( /<h1>#{t( :h1, :scope => :status_cat )}<\/h1>/ )
|
13
11
|
end
|
14
12
|
|
15
13
|
it 'uses the status_title helper' do
|
16
|
-
view.
|
14
|
+
expect( view ).to receive( :status_title )
|
17
15
|
render
|
18
16
|
end
|
19
17
|
|
20
18
|
it 'uses the status_table helper' do
|
21
|
-
view.
|
19
|
+
expect( view ).to receive( :status_table ).with( @checkers )
|
22
20
|
render
|
23
21
|
end
|
24
22
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe 'status_cat/status_mailer/failure.html.erb' do
|
4
2
|
|
5
3
|
before( :each ) do
|
@@ -8,7 +6,7 @@ describe 'status_cat/status_mailer/failure.html.erb' do
|
|
8
6
|
end
|
9
7
|
|
10
8
|
it 'uses the status_table helper' do
|
11
|
-
view.
|
9
|
+
expect( view ).to receive( :status_table ).with( @checkers )
|
12
10
|
render
|
13
11
|
end
|
14
12
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe 'status_cat/status_mailer/failure.text.erb' do
|
4
2
|
|
5
3
|
before( :each ) do
|
@@ -8,8 +6,7 @@ describe 'status_cat/status_mailer/failure.text.erb' do
|
|
8
6
|
end
|
9
7
|
|
10
8
|
it 'uses the status_table helper' do
|
11
|
-
view.
|
9
|
+
expect( view ).to receive( :status_report ).with( @checkers )
|
12
10
|
render
|
13
11
|
end
|
14
|
-
|
15
12
|
end
|