status_cat 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +161 -0
  4. data/Rakefile +31 -0
  5. data/app/assets/javascripts/status-cat/application.js +15 -0
  6. data/app/assets/stylesheets/status-cat/application.css +13 -0
  7. data/app/controllers/status_cat/status_controller.rb +26 -0
  8. data/app/helpers/status_cat/status_helper.rb +105 -0
  9. data/app/mailers/status_cat/status_mailer.rb +12 -0
  10. data/app/views/status_cat/status/index.html.erb +4 -0
  11. data/app/views/status_cat/status_mailer/failure.html.erb +9 -0
  12. data/app/views/status_cat/status_mailer/failure.text.erb +1 -0
  13. data/config/locales/en.yml +7 -0
  14. data/config/routes.rb +4 -0
  15. data/lib/status_cat/checkers/action_mailer.rb +31 -0
  16. data/lib/status_cat/checkers/active_record.rb +24 -0
  17. data/lib/status_cat/checkers/base.rb +36 -0
  18. data/lib/status_cat/checkers/delayed_job.rb +28 -0
  19. data/lib/status_cat/checkers/s3.rb +17 -0
  20. data/lib/status_cat/checkers/stripe.rb +19 -0
  21. data/lib/status_cat/config.rb +33 -0
  22. data/lib/status_cat/engine.rb +5 -0
  23. data/lib/status_cat/status.rb +37 -0
  24. data/lib/status_cat/version.rb +3 -0
  25. data/lib/status_cat.rb +22 -0
  26. data/lib/tasks/status_cat.rake +14 -0
  27. data/spec/controllers/status_cat/status_controller_spec.rb +36 -0
  28. data/spec/coverage_spec.rb +22 -0
  29. data/spec/data/report.txt +10 -0
  30. data/spec/data/report.txt.tmp +10 -0
  31. data/spec/data/status_report_format.txt +1 -0
  32. data/spec/data/status_report_format.txt.tmp +1 -0
  33. data/spec/dummy/README.rdoc +261 -0
  34. data/spec/dummy/Rakefile +7 -0
  35. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  36. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  37. data/spec/dummy/app/checkers/dummy.rb +10 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  39. data/spec/dummy/app/controllers/root_controller.rb +20 -0
  40. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  41. data/spec/dummy/app/views/layouts/admin.html.erb +14 -0
  42. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/spec/dummy/app/views/root/index.html.erb +8 -0
  44. data/spec/dummy/app/views/root/mail.html.erb +1 -0
  45. data/spec/dummy/config/application.rb +54 -0
  46. data/spec/dummy/config/boot.rb +10 -0
  47. data/spec/dummy/config/database.yml +25 -0
  48. data/spec/dummy/config/environment.rb +5 -0
  49. data/spec/dummy/config/environments/development.rb +32 -0
  50. data/spec/dummy/config/environments/production.rb +69 -0
  51. data/spec/dummy/config/environments/test.rb +33 -0
  52. data/spec/dummy/config/initializers/action_mailer.rb +16 -0
  53. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  54. data/spec/dummy/config/initializers/inflections.rb +15 -0
  55. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  56. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  57. data/spec/dummy/config/initializers/session_store.rb +8 -0
  58. data/spec/dummy/config/initializers/status_cat.rb +17 -0
  59. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  60. data/spec/dummy/config/locales/en.yml +5 -0
  61. data/spec/dummy/config/passwords.yml +5 -0
  62. data/spec/dummy/config/passwords.yml.sample +5 -0
  63. data/spec/dummy/config/routes.rb +11 -0
  64. data/spec/dummy/config.ru +4 -0
  65. data/spec/dummy/db/development.sqlite3 +0 -0
  66. data/spec/dummy/db/production.sqlite3 +0 -0
  67. data/spec/dummy/db/schema.rb +16 -0
  68. data/spec/dummy/db/test.sqlite3 +0 -0
  69. data/spec/dummy/log/development.log +889 -0
  70. data/spec/dummy/log/test.log +2474 -0
  71. data/spec/dummy/public/404.html +26 -0
  72. data/spec/dummy/public/422.html +26 -0
  73. data/spec/dummy/public/500.html +25 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/dummy/script/rails +6 -0
  76. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  77. data/spec/dummy/tmp/cache/assets/D03/1A0/sprockets%2F9007913fce90a3c1766dc0d8282bd10b +0 -0
  78. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  79. data/spec/dummy/tmp/cache/assets/D37/670/sprockets%2Fe230d6e60a0226de8748d1e26ee741cb +0 -0
  80. data/spec/dummy/tmp/cache/assets/D3D/4E0/sprockets%2F999ebb6862b2b7ca1b20b765f12704ed +0 -0
  81. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  82. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  83. data/spec/dummy/tmp/cache/assets/DCB/210/sprockets%2Fdf0a443455a9d359be2e931ba70ecdfe +0 -0
  84. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  85. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/0891c389c9f47b48b695b65602d93a57 +0 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/0edf8c53de2ee6fe74108f1ecc87e457 +0 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/264f02aaf3a74cd5a91b5575c69b784a +0 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/31c22cfbb3b5f7f9e1e9a013997ad8aa +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/400d7aa6ca317151fe36fc9f02ccfc4e +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/40da66d7323888023264d2f06b7525d4 +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/4bddf542ba5114155847240380cf6e7c +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/572759e0267736e8961ff1fad85cfe47 +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/6cec2a8a17b78e61daecff44044e1179 +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/952a706f512b208187110eff045a0e66 +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/c7d1ab26b0b22ab011a9d30f44014f06 +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/f1ebb0ab4631911fbbdf496685d8b7a0 +0 -0
  103. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  104. data/spec/dummy/tmp/pids/server.pid +1 -0
  105. data/spec/helpers/status_cat/status_helper_spec.rb +101 -0
  106. data/spec/lib/status_cat/checkers/action_mailer_spec.rb +72 -0
  107. data/spec/lib/status_cat/checkers/active_record_spec.rb +45 -0
  108. data/spec/lib/status_cat/checkers/base_spec.rb +56 -0
  109. data/spec/lib/status_cat/checkers/delayed_job_spec.rb +15 -0
  110. data/spec/lib/status_cat/checkers/s3_spec.rb +15 -0
  111. data/spec/lib/status_cat/checkers/stripe_spec.rb +15 -0
  112. data/spec/lib/status_cat/config_spec.rb +133 -0
  113. data/spec/lib/status_cat/engine_spec.rb +9 -0
  114. data/spec/lib/status_cat/status_spec.rb +120 -0
  115. data/spec/lib/status_cat/version_spec.rb +11 -0
  116. data/spec/lib/status_cat_spec.rb +21 -0
  117. data/spec/lib/tasks/status_cat.rake_spec.rb +32 -0
  118. data/spec/mailers/status_cat/status_mailer_spec.rb +38 -0
  119. data/spec/spec_helper.rb +50 -0
  120. data/spec/support/shared/checker.rb +25 -0
  121. data/spec/views/status_cat/status/index.html.erb_spec.rb +25 -0
  122. data/spec/views/status_cat/status_mailer/failure.html.erb_spec.rb +16 -0
  123. data/spec/views/status_cat/status_mailer/failure.text.erb_spec.rb +15 -0
  124. metadata +373 -0
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Status do
4
+
5
+ #############################################################################
6
+ # ::all
7
+ #############################################################################
8
+
9
+ describe '::all' do
10
+
11
+ it 'returns an array of enabled checkers' do
12
+ enabled = StatusCat::Config.instance.enabled
13
+ StatusCat::Config.instance.should_receive( :enabled ).and_return( enabled )
14
+
15
+ all = StatusCat::Status.all
16
+ all.should be_an_instance_of( Array )
17
+ all.length.should eql( StatusCat::Checkers::Base.descendants.length )
18
+ all.each { |checker| checker.should be_a_kind_of( StatusCat::Checkers::Base ) }
19
+ end
20
+
21
+ end
22
+
23
+ #############################################################################
24
+ # ::check
25
+ #############################################################################
26
+
27
+ describe '::check' do
28
+
29
+ def checker_array_should_have_names( actual, expected )
30
+ actual.should be_a_kind_of( Array )
31
+ actual.length.should eql( expected.length )
32
+ actual.each_index { |i| actual[ i ].name.should be( expected[ i ] ) }
33
+ end
34
+
35
+ it 'defaults to all checkers' do
36
+ names = StatusCat::Status.all.map { |checker| checker.name }
37
+ checkers = StatusCat::Status.check
38
+ checker_array_should_have_names( checkers, names )
39
+ end
40
+
41
+ it 'returns all checkers when :all is specified' do
42
+ names = StatusCat::Status.all.map { |checker| checker.name }
43
+ checkers = StatusCat::Status.check( :all )
44
+ checker_array_should_have_names( checkers, names )
45
+ end
46
+
47
+ it 'returns a single checker when given a single symbolic name' do
48
+ StatusCat::Status.check( :active_record ).should be_an_instance_of( StatusCat::Checkers::ActiveRecord )
49
+ end
50
+
51
+ it 'returns an array of checkers when given an array of symbolic name' do
52
+ names = [ :active_record, :action_mailer ]
53
+ checkers = StatusCat::Status.check( names )
54
+ checker_array_should_have_names( checkers, names )
55
+ end
56
+
57
+ end
58
+
59
+ #############################################################################
60
+ # ::cron
61
+ #############################################################################
62
+
63
+ describe '::cron' do
64
+
65
+ it 'delivers email if ::failed is not empty' do
66
+ failed = [ StatusCat::Checkers::Base.new ]
67
+ mail = StatusCat::StatusMailer.failure( failed )
68
+ StatusCat::Status.should_receive( :failed ).and_return( failed )
69
+ StatusCat::StatusMailer.should_receive( :failure ).with( failed ).and_return( mail )
70
+ StatusCat::Status.cron
71
+ end
72
+
73
+ it 'does not email when ::failed is empty' do
74
+ StatusCat::Status.should_receive( :failed ).and_return( [] )
75
+ StatusCat::StatusMailer.should_not_receive( :failure )
76
+ StatusCat::Status.cron
77
+ end
78
+
79
+ end
80
+
81
+ #############################################################################
82
+ # ::factory
83
+ #############################################################################
84
+
85
+ describe '::factory' do
86
+
87
+ it 'constructs a checker given its symbolic name' do
88
+ StatusCat::Status.factory( :action_mailer ).should be_an_instance_of( StatusCat::Checkers::ActionMailer )
89
+ StatusCat::Status.factory( :active_record ).should be_an_instance_of( StatusCat::Checkers::ActiveRecord )
90
+ end
91
+
92
+ end
93
+
94
+ #############################################################################
95
+ # ::failed
96
+ #############################################################################
97
+
98
+ describe '::failed' do
99
+
100
+ before( :each ) do
101
+ @pass = StatusCat::Checkers::Base.new
102
+
103
+ @fail = StatusCat::Checkers::Base.new
104
+ @fail.stub!( :status ).and_return( :fail )
105
+ end
106
+
107
+ it 'returns only failed checkers from ::all' do
108
+ StatusCat::Status.should_receive( :all ).and_return( [ @pass, @fail ] )
109
+ StatusCat::Status.failed.should eql( [ @fail ] )
110
+ end
111
+
112
+ it 'returns an empty list if all checkers pass' do
113
+ StatusCat::Status.should_receive( :all ).and_return( [ @pass ] )
114
+ StatusCat::Status.failed.should eql( [] )
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'version' do
4
+
5
+ it 'has a version constant' do
6
+ StatusCat::VERSION.should_not be_nil
7
+ StatusCat::VERSION.should be_an_instance_of( String )
8
+ StatusCat::VERSION.should =~ /\d+\.\d+\.\d+/
9
+ end
10
+
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat do
4
+
5
+ describe '::config' do
6
+
7
+ it 'returns the configuration' do
8
+ StatusCat.config.should be( StatusCat::Config.instance )
9
+ end
10
+
11
+ end
12
+
13
+ describe '::configure' do
14
+
15
+ it 'yields the configuration' do
16
+ StatusCat.configure { |config| config.should be( StatusCat::Config.instance ) }
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'rake'
3
+
4
+ describe 'status_cat rake tasks' do
5
+
6
+ before( :each ) do
7
+ @rake = Rake::Application.new
8
+ Rake.application = @rake
9
+ Rake::Task.define_task(:environment)
10
+ load 'lib/tasks/status_cat.rake'
11
+ end
12
+
13
+ describe 'rake status_cat:check' do
14
+
15
+ it 'puts the status report' do
16
+ Kernel.should_receive( :puts ).with( kind_of( String ) )
17
+ @rake[ 'status_cat:check' ].invoke
18
+ end
19
+
20
+ end
21
+
22
+ describe 'rake status_cat:cron' do
23
+
24
+ it 'calls StatusCat::Status.cron' do
25
+ StatusCat::Status.should_receive( :cron )
26
+ @rake[ 'status_cat:cron' ].invoke
27
+ end
28
+
29
+ end
30
+
31
+
32
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::StatusMailer do
4
+
5
+ it 'adds StatusCat::StatusHelper as a template helper' do
6
+ modules = StatusCat::StatusMailer._helpers.included_modules
7
+ modules.should include( StatusCat::StatusHelper )
8
+ end
9
+
10
+ describe '#failure' do
11
+
12
+ let( :mail ) { StatusCat::StatusMailer.failure( StatusCat::Status.all ) }
13
+ let( :config ) { StatusCat.config }
14
+
15
+ it 'uses the configured from address' do
16
+ mail.from.should_not be_nil
17
+ mail.from.should eql( [ config.from ] )
18
+ end
19
+
20
+ it 'uses the configured to address' do
21
+ mail.to.should_not be_nil
22
+ mail.to.should eql( [ config.to ] )
23
+ end
24
+
25
+ it 'uses the configured subject' do
26
+ mail.subject.should_not be_nil
27
+ mail.subject.should eql( config.subject )
28
+ end
29
+
30
+ it 'generates a multipart email with both text and html' do
31
+ mail.parts.first.content_type.should eql( 'text/plain; charset=UTF-8' )
32
+ mail.parts.second.content_type.should eql( 'text/html; charset=UTF-8' )
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,50 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+
4
+ require 'simplecov'
5
+
6
+ SimpleCov.start 'rails' do
7
+ add_filter '/vendor/'
8
+ add_filter '/spec/'
9
+ end
10
+
11
+ require File.expand_path('../dummy/config/environment', __FILE__)
12
+ require 'rspec/rails'
13
+ require 'rspec/autorun'
14
+
15
+ require 'spec_cat'
16
+
17
+ ENGINE_ROOT = File.join(File.dirname(__FILE__), '..')
18
+
19
+ # Requires supporting ruby files with custom matchers and macros, etc,
20
+ # in spec/support/ and its subdirectories.
21
+ Dir[File.join(ENGINE_ROOT, "spec/support/**/*.rb")].each {|f| require f }
22
+
23
+ RSpec.configure do |config|
24
+ # ## Mock Framework
25
+ #
26
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
27
+ #
28
+ # config.mock_with :mocha
29
+ # config.mock_with :flexmock
30
+ # config.mock_with :rr
31
+
32
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
33
+ #config.fixture_path = "#{::Rails.root}/spec/fixtures"
34
+
35
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
36
+ # examples within a transaction, remove the following line or assign false
37
+ # instead of true.
38
+ config.use_transactional_fixtures = true
39
+
40
+ # If true, the base class of anonymous controllers will be inferred
41
+ # automatically. This will be the default behavior in future versions of
42
+ # rspec-rails.
43
+ config.infer_base_class_for_anonymous_controllers = false
44
+
45
+ # Run specs in random order to surface order dependencies. If you find an
46
+ # order dependency and want to debug it, you can fix the order by providing
47
+ # the seed, which is printed after each run.
48
+ # --seed 1234
49
+ config.order = 'random'
50
+ end
@@ -0,0 +1,25 @@
1
+ shared_examples_for 'a status checker' do
2
+
3
+ it 'inherits from StatusCat::Checker' do
4
+ checker.should be_a_kind_of( StatusCat::Checkers::Base )
5
+ end
6
+
7
+ describe 'attributes' do
8
+
9
+ it 'has a name reader' do
10
+ expected = checker.class.to_s.split( '::' ).last.underscore.to_sym
11
+ checker.name.should eql( expected )
12
+ end
13
+
14
+ it 'has a value reader' do
15
+ checker.value.should eql( checker.value )
16
+ end
17
+
18
+ it 'has a status reader' do
19
+ checker.status.should eql( checker.status )
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'status_cat/status/index.html.erb' do
4
+
5
+ before( :each ) do
6
+ @checkers = StatusCat::Status.all
7
+ assign( :checkers, @checkers )
8
+ end
9
+
10
+ it 'includes an h1 tag' do
11
+ render
12
+ rendered.should have_selector( :h1, :content => t( :h1, :scope => :status_cat ) )
13
+ end
14
+
15
+ it 'uses the status_title helper' do
16
+ view.should_receive( :status_title )
17
+ render
18
+ end
19
+
20
+ it 'uses the status_table helper' do
21
+ view.should_receive( :status_table ).with( @checkers )
22
+ render
23
+ end
24
+
25
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'status_cat/status_mailer/failure.html.erb' do
4
+
5
+ before( :each ) do
6
+ @checkers = StatusCat::Status.all
7
+ assign( :checkers, @checkers )
8
+ end
9
+
10
+ it 'uses the status_table helper' do
11
+ view.should_receive( :status_table ).with( @checkers )
12
+ render
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'status_cat/status_mailer/failure.text.erb' do
4
+
5
+ before( :each ) do
6
+ @checkers = StatusCat::Status.all
7
+ assign( :checkers, @checkers )
8
+ end
9
+
10
+ it 'uses the status_table helper' do
11
+ view.should_receive( :status_report ).with( @checkers )
12
+ render
13
+ end
14
+
15
+ end