status_cat 0.0.8

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.
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,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1 @@
1
+ 7028
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::StatusHelper do
4
+
5
+ let( :checker ) { StatusCat::Checkers::ActiveRecord.new }
6
+ let( :name ) { t( :name, :scope => :status_cat ).freeze }
7
+ let( :value ) { t( :value, :scope => :status_cat ).freeze }
8
+ let( :status ) { t( :status, :scope => :status_cat ).freeze }
9
+ let( :ok ) { t( :ok, :scope => :status_cat ).freeze }
10
+
11
+ describe '#status_header' do
12
+
13
+ it 'generates a status table header' do
14
+ expected = "<tr><th>#{name}</th><th>#{value}</th><th>#{status}</th></tr>"
15
+ helper.status_header.should eql( expected )
16
+ end
17
+
18
+ end
19
+
20
+ describe '#status_row' do
21
+
22
+ it 'generates a status table row' do
23
+ expected = "<tr><td style=\"#{helper.status_style( checker )}\">#{checker.name}</td><td>#{checker.value}</td><td>#{ok}</td></tr>"
24
+ helper.status_row( checker ).should eql( expected )
25
+ end
26
+
27
+ it 'uses status_style to style the status column' do
28
+ style = :gangnam
29
+ helper.should_receive( :status_style ).and_return( style )
30
+ expected = "<tr><td style=\"#{style}\">#{checker.name}</td><td>#{checker.value}</td><td>#{ok}</td></tr>"
31
+ helper.status_row( checker ).should eql( expected )
32
+ end
33
+
34
+ end
35
+
36
+ describe '#status_style' do
37
+
38
+ it 'returns a green background when the status is nil' do
39
+ checker.should_receive( :status ).and_return( nil )
40
+ helper.status_style( checker ).should eql( 'background-color: green' )
41
+ end
42
+
43
+ it 'returns a red background when the status is not nil' do
44
+ checker.should_receive( :status ).and_return( :fail )
45
+ helper.status_style( checker ).should eql( 'background-color: red' )
46
+ end
47
+
48
+ end
49
+
50
+ describe '#status_table' do
51
+
52
+ it 'generates a status table' do
53
+ expected = "<table border=\"1\">#{helper.status_header}#{helper.status_row( checker )}</table>"
54
+ helper.status_table( [ checker ] ).should eql( expected )
55
+ end
56
+
57
+ end
58
+
59
+ describe '#status_title' do
60
+
61
+ it 'generates a page title' do
62
+ expected = "<h1>#{t( :h1, :scope => :status_cat )}</h1>"
63
+ helper.status_title.should eql( expected )
64
+ end
65
+
66
+ end
67
+
68
+ describe '#status_report' do
69
+
70
+ it 'generates a text status report' do
71
+ all = StatusCat::Status.all
72
+ helper.status_report( all ).should eql_file( 'spec/data/report.txt' )
73
+ end
74
+
75
+ end
76
+
77
+ describe '#status_report_format' do
78
+
79
+ it 'generates a format string and length based on the max length of the given checkers' do
80
+ status_report_format = helper.status_report_format( StatusCat::Status.all ).to_s
81
+ status_report_format.should eql_file( 'spec/data/status_report_format.txt' )
82
+ end
83
+
84
+ end
85
+
86
+ describe '#status_report_header' do
87
+
88
+ it 'generates a header' do
89
+ expected = sprintf( StatusCat::Checkers::Base::FORMAT, name, value, status )
90
+ helper.status_report_header.should eql( expected )
91
+ end
92
+
93
+ it 'accepts a format string' do
94
+ format = '%s * %s * %s'
95
+ expected = sprintf( format, name, value, status )
96
+ helper.status_report_header( format ).should eql( expected )
97
+ end
98
+
99
+ end
100
+
101
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::ActionMailer do
4
+
5
+ let( :checker ) { StatusCat::Checkers::ActionMailer.new.freeze }
6
+
7
+ it_should_behave_like 'a status checker'
8
+
9
+ it 'provides configuration' do
10
+ checker.config.should eql( ::ActionMailer::Base.smtp_settings )
11
+ end
12
+
13
+ it 'constructs a value from the configuration' do
14
+ expected = "#{checker.config[ :address ]}:#{checker.config[ :port ]}"
15
+ checker.value.should eql( expected )
16
+ end
17
+
18
+ #############################################################################
19
+ # status
20
+ #############################################################################
21
+
22
+ describe '#status' do
23
+
24
+ before( :each ) do
25
+ ::ActionMailer::Base.delivery_method = :smtp
26
+ end
27
+
28
+ after( :each ) do
29
+ ::ActionMailer::Base.delivery_method = :test
30
+ end
31
+
32
+ #############################################################################
33
+ # pass
34
+ #############################################################################
35
+
36
+ context 'pass' do
37
+
38
+ it 'passes if it can make an SMTP connection' do
39
+ Net::SMTP.should_receive( :start )
40
+ checker = StatusCat::Checkers::ActionMailer.new
41
+ checker.status.should be_nil
42
+ end
43
+
44
+ end
45
+
46
+ #############################################################################
47
+ # fail
48
+ #############################################################################
49
+
50
+ context 'fail' do
51
+
52
+ let( :exception ) { Net::SMTPAuthenticationError.new }
53
+
54
+ it 'returns an error message if it can not make an SMTP connection' do
55
+ Net::SMTP.should_receive( :start ).and_raise( exception )
56
+ checker = StatusCat::Checkers::ActionMailer.new
57
+ checker.status.should be( exception )
58
+ end
59
+
60
+ it 'returns an error message if it can not send a message' do
61
+ smtp = Object.new
62
+ smtp.stub!( :send_message ).and_raise( exception )
63
+ Net::SMTP.should_receive( :start ).and_yield( smtp )
64
+ checker = StatusCat::Checkers::ActionMailer.new
65
+ checker.status.should be( exception )
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::ActiveRecord do
4
+
5
+ let( :checker ) { StatusCat::Checkers::ActiveRecord.new.freeze }
6
+
7
+ it_should_behave_like 'a status checker'
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
+ it 'constructs a value from the configuration' do
16
+ expected = "#{checker.config[ :adapter ]}:#{checker.config[ :username ]}@#{checker.config[ :database ]}"
17
+ checker.value.should eql( expected )
18
+ end
19
+
20
+ describe '#status' do
21
+
22
+ context 'pass' do
23
+
24
+ it 'passes if it can execute a query against the database' do
25
+ ActiveRecord::Base.connection.stub!( :execute )
26
+ checker = StatusCat::Checkers::ActiveRecord.new
27
+ checker.status.should be_nil
28
+ end
29
+
30
+ end
31
+
32
+ context 'fail' do
33
+
34
+ it 'returns an error message if it fails to query the database' do
35
+ fail = 'This is only a test'
36
+ ActiveRecord::Base.connection.should_receive( :execute ).and_raise( fail )
37
+ checker = StatusCat::Checkers::ActiveRecord.new
38
+ checker.status.to_s.should eql( fail )
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::Base do
4
+
5
+ let( :checker ) { StatusCat::Checkers::Base.new }
6
+
7
+ describe '#name' do
8
+
9
+ it 'generates a symbolized class name' do
10
+ checker.name.should be( :base )
11
+ end
12
+
13
+ end
14
+
15
+ describe 'attributes' do
16
+
17
+ it 'has value and status readers' do
18
+ checker.value.should be_nil
19
+ checker.status.should be_nil
20
+ end
21
+
22
+ end
23
+
24
+ describe '#to_s' do
25
+
26
+ before( :each ) do
27
+ checker.stub!( :value ).and_return( 'secret' )
28
+ checker.stub!( :status ).and_return( 'fail' )
29
+ end
30
+
31
+ it 'generates a string' do
32
+ checker.to_s.should eql( "base | secret | fail\n" )
33
+ end
34
+
35
+ it 'accepts a format' do
36
+ checker.to_s( '%s * %s * %s' ).should eql( 'base * secret * fail' )
37
+ end
38
+
39
+ end
40
+
41
+ describe '#fail_on_exception' do
42
+
43
+ it 'returns an exception if raised from the block given' do
44
+ error = 'test'
45
+ status = checker.send( :fail_on_exception ) { raise error }
46
+ status.to_s.should eql( error )
47
+ end
48
+
49
+ it 'returns the results of the block when there is no exception' do
50
+ status = checker.send( :fail_on_exception ) { true }
51
+ status.should be_true
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::DelayedJob do
4
+
5
+ let( :checker ) { StatusCat::Checkers::DelayedJob.new.freeze }
6
+
7
+ before( :each ) do
8
+
9
+ end
10
+
11
+ it_should_behave_like 'a status checker'
12
+
13
+ it 'should be specced better'
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::S3 do
4
+
5
+ let( :checker ) { StatusCat::Checkers::S3.new.freeze }
6
+
7
+ before( :each ) do
8
+
9
+ end
10
+
11
+ it_should_behave_like 'a status checker'
12
+
13
+ it 'should be specced better'
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Checkers::Stripe do
4
+
5
+ let( :checker ) { StatusCat::Checkers::Stripe.new.freeze }
6
+
7
+ before( :each ) do
8
+
9
+ end
10
+
11
+ it_should_behave_like 'a status checker'
12
+
13
+ it 'should be specced better'
14
+
15
+ end
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Config do
4
+
5
+ let( :config ) { StatusCat::Config.instance }
6
+
7
+ it 'is a singleton' do
8
+ config.should be( StatusCat::Config.instance )
9
+ end
10
+
11
+ describe 'attributes' do
12
+
13
+ it 'has an #authenticate accessor' do
14
+ config.authenticate = StatusCat::Config::NIL_PROC
15
+ config.authenticate = config.authenticate
16
+ config.authenticate.should eql( config.authenticate )
17
+ end
18
+
19
+ it 'has an #authorize accessor' do
20
+ config.authorize.should_not be_nil
21
+ config.authorize = config.authorize
22
+ config.authorize.should eql( config.authorize )
23
+ end
24
+
25
+ it 'has an #enabled accessor' do
26
+ config.enabled.should_not be_nil
27
+ config.enabled = config.enabled
28
+ config.enabled.should eql( config.enabled )
29
+ end
30
+
31
+ it 'has a #from accessor' do
32
+ config.from.should_not be_nil
33
+ config.from = config.from
34
+ config.from.should eql( config.from )
35
+ end
36
+
37
+ it 'has a #layout accessor' do
38
+ config.layout.should_not be_nil
39
+ config.layout = config.layout
40
+ config.layout.should eql( config.layout )
41
+ end
42
+
43
+ it 'has a #noreply accessor' do
44
+ config.noreply.should_not be_nil
45
+ config.noreply = config.noreply
46
+ config.noreply.should eql( config.noreply )
47
+ end
48
+
49
+ it 'has a #to accessor' do
50
+ config.to.should_not be_nil
51
+ config.to = config.to
52
+ config.to.should eql( config.to )
53
+ end
54
+
55
+ it 'has an #subject accessor' do
56
+ config.subject.should_not be_nil
57
+ config.subject = config.subject
58
+ config.subject.should eql( config.subject )
59
+ end
60
+
61
+ end
62
+
63
+ describe '#initialize' do
64
+
65
+ it 'defaults the #enabled list to all StatusCat::Checkers::Base subclasses' do
66
+ descendants = StatusCat::Checkers::Base.descendants
67
+ StatusCat::Checkers::Base.should_receive( :descendants ).and_return( descendants )
68
+
69
+ config.enabled = nil
70
+ config.send( :initialize )
71
+ config.enabled.should_not be_nil
72
+ end
73
+
74
+ end
75
+
76
+ describe '#authenticate_with' do
77
+
78
+ it 'accepts a block' do
79
+ config.authenticate = nil
80
+ config.authenticate_with do
81
+ true
82
+ end
83
+
84
+ expect( config.authenticate ).to_not be_nil
85
+ end
86
+
87
+ it 'returns a block' do
88
+ @test = false
89
+ config.authenticate_with do
90
+ @test = true
91
+ end
92
+
93
+ instance_eval( &config.authenticate_with )
94
+ expect( @test ).to be_true
95
+ end
96
+
97
+ it 'returns a nil proc if none has been set' do
98
+ config.authenticate = nil
99
+ instance_eval( &config.authenticate_with )
100
+ end
101
+
102
+ end
103
+
104
+ describe '#authorize_with' do
105
+
106
+ it 'accepts a block' do
107
+ config.authorize = nil
108
+ config.authorize_with do
109
+ true
110
+ end
111
+
112
+ expect( config.authorize ).to_not be_nil
113
+ end
114
+
115
+ it 'returns a block' do
116
+ @test = false
117
+ config.authorize_with do
118
+ @test = true
119
+ end
120
+
121
+ instance_eval( &config.authorize_with )
122
+ expect( @test ).to be_true
123
+ end
124
+
125
+ it 'returns a nil proc if none has been set' do
126
+ config.authorize = nil
127
+ instance_eval( &config.authorize_with )
128
+ end
129
+
130
+ end
131
+
132
+ end
133
+
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe StatusCat::Engine do
4
+
5
+ it 'isolates the StatusCat namespace' do
6
+ StatusCat::Engine.isolated.should be_true
7
+ end
8
+
9
+ end