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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -20
  3. data/lib/status_cat/checkers/delayed_job.rb +2 -2
  4. data/lib/status_cat/checkers/fitbit.rb +20 -0
  5. data/lib/status_cat/checkers/profilesio.rb +13 -0
  6. data/lib/status_cat/checkers/send_hub.rb +13 -0
  7. data/lib/status_cat/checkers/twilio.rb +13 -0
  8. data/lib/status_cat/status.rb +1 -1
  9. data/lib/status_cat/version.rb +1 -1
  10. data/lib/status_cat.rb +4 -0
  11. data/spec/controllers/status_cat/status_controller_spec.rb +8 -10
  12. data/spec/coverage_spec.rb +1 -3
  13. data/spec/dummy/config/environments/test.rb +1 -1
  14. data/spec/dummy/db/development.sqlite3 +0 -0
  15. data/spec/dummy/db/test.sqlite3 +0 -0
  16. data/spec/dummy/log/development.log +0 -1232
  17. data/spec/dummy/log/test.log +12344 -6383
  18. data/spec/helpers/status_cat/status_helper_spec.rb +17 -28
  19. data/spec/lib/status_cat/checkers/action_mailer_spec.rb +9 -15
  20. data/spec/lib/status_cat/checkers/active_record_spec.rb +5 -11
  21. data/spec/lib/status_cat/checkers/base_spec.rb +9 -16
  22. data/spec/lib/status_cat/checkers/delayed_job_spec.rb +4 -10
  23. data/spec/lib/status_cat/checkers/fitbit_spec.rb +33 -0
  24. data/spec/lib/status_cat/checkers/profilesio_spec.rb +38 -0
  25. data/spec/lib/status_cat/checkers/s3_spec.rb +1 -3
  26. data/spec/lib/status_cat/checkers/send_hub_spec.rb +33 -0
  27. data/spec/lib/status_cat/checkers/stripe_spec.rb +1 -3
  28. data/spec/lib/status_cat/checkers/twilio_spec.rb +33 -0
  29. data/spec/lib/status_cat/config_spec.rb +36 -29
  30. data/spec/lib/status_cat/engine_spec.rb +1 -4
  31. data/spec/lib/status_cat/status_spec.rb +19 -27
  32. data/spec/lib/status_cat/version_spec.rb +3 -6
  33. data/spec/lib/status_cat_spec.rb +2 -7
  34. data/spec/lib/tasks/status_cat.rake_spec.rb +2 -7
  35. data/spec/mailers/status_cat/status_mailer_spec.rb +9 -13
  36. data/spec/spec_helper.rb +21 -1
  37. data/spec/support/shared/checker.rb +4 -6
  38. data/spec/views/status_cat/status/index.html.erb_spec.rb +3 -5
  39. data/spec/views/status_cat/status_mailer/failure.html.erb_spec.rb +1 -3
  40. data/spec/views/status_cat/status_mailer/failure.text.erb_spec.rb +1 -4
  41. metadata +107 -41
  42. data/spec/data/report.txt +0 -10
  43. data/spec/data/report.txt.tmp +0 -10
  44. data/spec/data/status_report_format.txt +0 -1
  45. data/spec/data/status_report_format.txt.tmp +0 -1
  46. data/spec/dummy/config/passwords.yml +0 -5
  47. data/spec/dummy/db/production.sqlite3 +0 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/0891c389c9f47b48b695b65602d93a57 +0 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/400d7aa6ca317151fe36fc9f02ccfc4e +0 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/40da66d7323888023264d2f06b7525d4 +0 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/4bddf542ba5114155847240380cf6e7c +0 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/572759e0267736e8961ff1fad85cfe47 +0 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/6cec2a8a17b78e61daecff44044e1179 +0 -0
  54. data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::StatusHelper do
4
2
 
5
3
  let( :checker ) { StatusCat::Checkers::ActiveRecord.new }
@@ -12,25 +10,23 @@ describe StatusCat::StatusHelper do
12
10
 
13
11
  it 'generates a status table header' do
14
12
  expected = "<tr><th>#{name}</th><th>#{value}</th><th>#{status}</th></tr>"
15
- helper.status_header.should eql( expected )
13
+ expect( helper.status_header ).to eql( expected )
16
14
  end
17
-
18
15
  end
19
16
 
20
17
  describe '#status_row' do
21
18
 
22
19
  it 'generates a status table row' do
23
20
  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 )
21
+ expect( helper.status_row( checker ) ).to eql( expected )
25
22
  end
26
23
 
27
24
  it 'uses status_style to style the status column' do
28
25
  style = :gangnam
29
- helper.should_receive( :status_style ).and_return( style )
26
+ expect( helper ).to receive( :status_style ).and_return( style )
30
27
  expected = "<tr><td style=\"#{style}\">#{checker.name}</td><td>#{checker.value}</td><td>#{ok}</td></tr>"
31
- helper.status_row( checker ).should eql( expected )
28
+ expect( helper.status_row( checker ) ).to eql( expected )
32
29
  end
33
-
34
30
  end
35
31
 
36
32
  describe '#status_cell' do
@@ -44,77 +40,70 @@ describe StatusCat::StatusHelper do
44
40
  expected = "<td><ul><li>foo</li><li>bar</li></ul></td>"
45
41
  expect( helper.status_cell( [ 'foo', 'bar' ] ) ).to eql( expected )
46
42
  end
47
-
48
43
  end
49
44
 
50
45
  describe '#status_style' do
51
46
 
52
47
  it 'returns a green background when the status is nil' do
53
- checker.should_receive( :status ).and_return( nil )
54
- helper.status_style( checker ).should eql( 'background-color: green' )
48
+ expect( checker ).to receive( :status ).and_return( nil )
49
+ expect( helper.status_style( checker ) ).to eql( 'background-color: green' )
55
50
  end
56
51
 
57
52
  it 'returns a red background when the status is not nil' do
58
- checker.should_receive( :status ).and_return( :fail )
59
- helper.status_style( checker ).should eql( 'background-color: red' )
53
+ expect( checker ).to receive( :status ).and_return( :fail )
54
+ expect( helper.status_style( checker ) ).to eql( 'background-color: red' )
60
55
  end
61
-
62
56
  end
63
57
 
64
58
  describe '#status_table' do
65
59
 
66
60
  it 'generates a status table' do
67
61
  expected = "<table border=\"1\">#{helper.status_header}#{helper.status_row( checker )}</table>"
68
- helper.status_table( [ checker ] ).should eql( expected )
62
+ expect( helper.status_table( [ checker ] ) ).to eql( expected )
69
63
  end
70
-
71
64
  end
72
65
 
73
66
  describe '#status_title' do
74
67
 
75
68
  it 'generates a page title' do
76
69
  expected = "<h1>#{t( :h1, :scope => :status_cat )}</h1>"
77
- helper.status_title.should eql( expected )
70
+ expect( helper.status_title ).to eql( expected )
78
71
  end
79
-
80
72
  end
81
73
 
82
74
  describe '#status_report' do
83
75
 
84
76
  it 'generates a text status report' do
85
77
  all = StatusCat::Status.all
86
- all.each { |s| s.stub( :status ).and_return( nil ) }
78
+ all.each { |s| allow( s ).to receive( :status ).and_return( nil ) }
87
79
 
88
- helper.status_report( all ).should eql_file( 'spec/data/report.txt' )
80
+ actual = helper.status_report( all )
81
+ all.each { |s| expect( actual ).to match( /#{s}/ ) }
89
82
  end
90
-
91
83
  end
92
84
 
93
85
  describe '#status_report_format' do
94
86
 
95
87
  it 'generates a format string and length based on the max length of the given checkers' do
96
88
  all = StatusCat::Status.all
97
- all.each { |s| s.stub( :status ).and_return( nil ) }
89
+ all.each { |s| allow( s ).to receive( :status ).and_return( nil ) }
98
90
 
99
91
  status_report_format = helper.status_report_format( all ).to_s
100
- status_report_format.should eql_file( 'spec/data/status_report_format.txt' )
92
+ expect( status_report_format ).to match( /\["%\d+s | %\d+s | %\d+s\n", \d+\]/ )
101
93
  end
102
-
103
94
  end
104
95
 
105
96
  describe '#status_report_header' do
106
97
 
107
98
  it 'generates a header' do
108
99
  expected = sprintf( StatusCat::Checkers::Base::FORMAT, name, value, status )
109
- helper.status_report_header.should eql( expected )
100
+ expect( helper.status_report_header ).to eql( expected )
110
101
  end
111
102
 
112
103
  it 'accepts a format string' do
113
104
  format = '%s * %s * %s'
114
105
  expected = sprintf( format, name, value, status )
115
- helper.status_report_header( format ).should eql( expected )
106
+ expect( helper.status_report_header( format ) ).to eql( expected )
116
107
  end
117
-
118
108
  end
119
-
120
109
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::Checkers::ActionMailer do
4
2
 
5
3
  let( :checker ) { StatusCat::Checkers::ActionMailer.new.freeze }
@@ -7,12 +5,12 @@ describe StatusCat::Checkers::ActionMailer do
7
5
  it_should_behave_like 'a status checker'
8
6
 
9
7
  it 'provides configuration' do
10
- checker.config.should eql( ::ActionMailer::Base.smtp_settings )
8
+ expect( checker.config ).to eql( ::ActionMailer::Base.smtp_settings )
11
9
  end
12
10
 
13
11
  it 'constructs a value from the configuration' do
14
12
  expected = "#{checker.config[ :address ]}:#{checker.config[ :port ]}"
15
- checker.value.should eql( expected )
13
+ expect( checker.value ).to eql( expected )
16
14
  end
17
15
 
18
16
  #############################################################################
@@ -36,11 +34,10 @@ describe StatusCat::Checkers::ActionMailer do
36
34
  context 'pass' do
37
35
 
38
36
  it 'passes if it can make an SMTP connection' do
39
- Net::SMTP.should_receive( :start )
37
+ expect( Net::SMTP ).to receive( :start )
40
38
  checker = StatusCat::Checkers::ActionMailer.new
41
- checker.status.should be_nil
39
+ expect( checker.status ).to be_nil
42
40
  end
43
-
44
41
  end
45
42
 
46
43
  #############################################################################
@@ -52,21 +49,18 @@ describe StatusCat::Checkers::ActionMailer do
52
49
  let( :exception ) { Net::SMTPAuthenticationError.new }
53
50
 
54
51
  it 'returns an error message if it can not make an SMTP connection' do
55
- Net::SMTP.should_receive( :start ).and_raise( exception )
52
+ expect( Net::SMTP ).to receive( :start ).and_raise( exception )
56
53
  checker = StatusCat::Checkers::ActionMailer.new
57
- checker.status.should be( exception )
54
+ expect( checker.status ).to be( exception )
58
55
  end
59
56
 
60
57
  it 'returns an error message if it can not send a message' do
61
58
  smtp = Object.new
62
- smtp.stub( :send_message ).and_raise( exception )
63
- Net::SMTP.should_receive( :start ).and_yield( smtp )
59
+ allow( smtp ).to receive( :send_message ).and_raise( exception )
60
+ allow( Net::SMTP ).to receive( :start ).and_yield( smtp )
64
61
  checker = StatusCat::Checkers::ActionMailer.new
65
- checker.status.should be( exception )
62
+ expect( checker.status ).to be( exception )
66
63
  end
67
-
68
64
  end
69
-
70
65
  end
71
-
72
66
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::Checkers::ActiveRecord do
4
2
 
5
3
  let( :checker ) { StatusCat::Checkers::ActiveRecord.new.freeze }
@@ -10,7 +8,7 @@ describe StatusCat::Checkers::ActiveRecord do
10
8
  config = { :adapter => 'postgres', :username => 'dba', :database => 'test' }
11
9
  expect( ::ActiveRecord::Base ).to receive( :connection_config ).and_return( config )
12
10
  expected = "#{config[ :adapter ]}:#{config[ :username ]}@#{config[ :database ]}"
13
- checker.value.should eql( expected )
11
+ expect( checker.value ).to eql( expected )
14
12
  end
15
13
 
16
14
  describe '#status' do
@@ -18,24 +16,20 @@ describe StatusCat::Checkers::ActiveRecord do
18
16
  context 'pass' do
19
17
 
20
18
  it 'passes if it can execute a query against the database' do
21
- ActiveRecord::Base.connection.stub( :execute )
19
+ allow( ActiveRecord::Base.connection ).to receive( :execute )
22
20
  checker = StatusCat::Checkers::ActiveRecord.new
23
- checker.status.should be_nil
21
+ expect( checker.status ).to be_nil
24
22
  end
25
-
26
23
  end
27
24
 
28
25
  context 'fail' do
29
26
 
30
27
  it 'returns an error message if it fails to query the database' do
31
28
  fail = 'This is only a test'
32
- ActiveRecord::Base.connection.should_receive( :execute ).and_raise( fail )
29
+ expect( ActiveRecord::Base.connection ).to receive( :execute ).and_raise( fail )
33
30
  checker = StatusCat::Checkers::ActiveRecord.new
34
- checker.status.to_s.should eql( fail )
31
+ expect( checker.status.to_s ).to eql( fail )
35
32
  end
36
-
37
33
  end
38
-
39
34
  end
40
-
41
35
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::Checkers::Base do
4
2
 
5
3
  let( :checker ) { StatusCat::Checkers::Base.new }
@@ -7,35 +5,32 @@ describe StatusCat::Checkers::Base do
7
5
  describe '#name' do
8
6
 
9
7
  it 'generates a symbolized class name' do
10
- checker.name.should be( :base )
8
+ expect( checker.name ).to be( :base )
11
9
  end
12
-
13
10
  end
14
11
 
15
12
  describe 'attributes' do
16
13
 
17
14
  it 'has value and status readers' do
18
- checker.value.should be_nil
19
- checker.status.should be_nil
15
+ expect( checker.value ).to be_nil
16
+ expect( checker.status ).to be_nil
20
17
  end
21
-
22
18
  end
23
19
 
24
20
  describe '#to_s' do
25
21
 
26
22
  before( :each ) do
27
- checker.stub( :value ).and_return( 'secret' )
28
- checker.stub( :status ).and_return( 'fail' )
23
+ allow( checker ).to receive( :value ).and_return( 'secret' )
24
+ allow( checker ).to receive( :status ).and_return( 'fail' )
29
25
  end
30
26
 
31
27
  it 'generates a string' do
32
- checker.to_s.should eql( "base | secret | fail\n" )
28
+ expect( checker.to_s ).to eql( "base | secret | fail\n" )
33
29
  end
34
30
 
35
31
  it 'accepts a format' do
36
- checker.to_s( '%s * %s * %s' ).should eql( 'base * secret * fail' )
32
+ expect( checker.to_s( '%s * %s * %s' ) ).to eql( 'base * secret * fail' )
37
33
  end
38
-
39
34
  end
40
35
 
41
36
  describe '#fail_on_exception' do
@@ -43,14 +38,12 @@ describe StatusCat::Checkers::Base do
43
38
  it 'returns an exception if raised from the block given' do
44
39
  error = 'test'
45
40
  status = checker.send( :fail_on_exception ) { raise error }
46
- status.to_s.should eql( error )
41
+ expect( status.to_s ).to eql( error )
47
42
  end
48
43
 
49
44
  it 'returns the results of the block when there is no exception' do
50
45
  status = checker.send( :fail_on_exception ) { true }
51
- status.should be_true
46
+ expect( status ).to be( true )
52
47
  end
53
-
54
48
  end
55
-
56
49
  end
@@ -1,14 +1,9 @@
1
- require 'spec_helper'
2
1
  require 'delayed_job_active_record'
3
2
 
4
3
  describe StatusCat::Checkers::DelayedJob do
5
4
 
6
5
  let( :checker ) { StatusCat::Checkers::DelayedJob.new.freeze }
7
6
 
8
- before( :each ) do
9
-
10
- end
11
-
12
7
  it_should_behave_like 'a status checker'
13
8
 
14
9
  it 'tolerates Delayed::Job being undefined' do
@@ -18,23 +13,22 @@ describe StatusCat::Checkers::DelayedJob do
18
13
  end
19
14
 
20
15
  it 'fails if there is an exception' do
21
- ActiveRecord::Base.connection.should_receive( :execute ).and_raise( :error )
16
+ expect( ActiveRecord::Base.connection ).to receive( :execute ).and_raise( :error )
22
17
  expect( checker.status ).to_not be_nil
23
18
  end
24
19
 
25
20
  it 'fails if there are expired jobs' do
26
- ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [1] )
21
+ expect( ActiveRecord::Base.connection ).to receive( :execute ).and_return( [1], [1] )
27
22
  expect( checker.status ).to_not be_nil
28
23
  end
29
24
 
30
25
  it 'passes if there are no expired jobs' do
31
- ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [0] )
26
+ expect( ActiveRecord::Base.connection ).to receive( :execute ).and_return( [1], [0] )
32
27
  expect( checker.status ).to be_nil
33
28
  end
34
29
 
35
30
  it 'uses the job count as the value' do
36
- ActiveRecord::Base.connection.should_receive( :execute ).and_return( [1], [0] )
31
+ expect( ActiveRecord::Base.connection ).to receive( :execute ).and_return( [1], [0] )
37
32
  expect( checker.value ).to eql( 1 )
38
33
  end
39
-
40
34
  end
@@ -0,0 +1,33 @@
1
+ describe StatusCat::Checkers::Fitbit do
2
+
3
+ let( :checker ) { StatusCat::Checkers::Fitbit.new.freeze }
4
+
5
+ it_should_behave_like 'a status checker'
6
+
7
+ describe '#initialize' do
8
+
9
+ it 'sets the value' do
10
+ expect( checker.value ).to eql( ENV[ 'FITBIT_CONSUMER_KEY' ] )
11
+ end
12
+
13
+ context 'pass' do
14
+
15
+ it 'passes if it can connect to Fitbit' do
16
+ expect( checker.status ).to be_nil
17
+ end
18
+ end
19
+
20
+ context 'fail' do
21
+
22
+ it 'fails if it receives errors' do
23
+ expect( @fitgem ).to receive( :user_info ).and_return( { 'errors' => 'this is only a test' } )
24
+ expect( checker.status ).to_not be_nil
25
+ end
26
+
27
+ it 'fails if there is an exception' do
28
+ expect( @fitgem ).to receive( :user_info ).and_raise( 'This is only a test' )
29
+ expect( checker.status ).to_not be_nil
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ describe StatusCat::Checkers::Profilesio do
2
+
3
+ let( :checker ) { StatusCat::Checkers::Profilesio.new.freeze }
4
+ let( :response ) { double( "response", :code => 200 ) }
5
+ let( :key ) { 'env_profilesio_key' }
6
+
7
+ before( :each ) do
8
+ allow( HTTParty ).to receive( :get ).and_return( response )
9
+ ENV['PROFILESIO_KEY'] = key
10
+ end
11
+
12
+ it_should_behave_like 'a status checker'
13
+
14
+ it 'sets the value' do
15
+ expect( checker.value ).to eql( key )
16
+ end
17
+
18
+ context 'pass' do
19
+
20
+ it 'passes on connection to Profilesio' do
21
+ expect( checker.status ).to be_nil
22
+ end
23
+
24
+ end
25
+
26
+ context 'fail' do
27
+
28
+ it 'fails if it receives a non 200 code' do
29
+ expect( response ).to receive( :code ).and_return( 404 )
30
+ expect( checker.status ).to_not be_nil
31
+ end
32
+
33
+ it 'fails if there is an exception' do
34
+ expect( response ).to receive( :code ).and_raise( 'No code for you!' )
35
+ expect( checker.status ).to_not be_nil
36
+ end
37
+ end
38
+ end
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'aws-sdk'
3
2
 
4
3
  describe StatusCat::Checkers::S3 do
@@ -6,7 +5,7 @@ describe StatusCat::Checkers::S3 do
6
5
  let( :checker ) { StatusCat::Checkers::S3.new.freeze }
7
6
 
8
7
  before( :each ) do
9
- AWS::S3.stub( :new ).and_return( @s3 = double( AWS::S3 ) )
8
+ allow( AWS::S3 ).to receive( :new ).and_return( @s3 = double( AWS::S3 ) )
10
9
  end
11
10
 
12
11
  it_should_behave_like 'a status checker'
@@ -35,5 +34,4 @@ describe StatusCat::Checkers::S3 do
35
34
  expect( @s3 ).to receive( :buckets ).and_return( [ 1 ] )
36
35
  expect( checker.status ).to be_nil
37
36
  end
38
-
39
37
  end
@@ -0,0 +1,33 @@
1
+ describe StatusCat::Checkers::SendHub do
2
+
3
+ let( :checker ) { StatusCat::Checkers::SendHub.new.freeze }
4
+
5
+ it_should_behave_like 'a status checker'
6
+
7
+ describe '#initialize' do
8
+
9
+ it 'sets the value' do
10
+ expect( checker.value ).to eql( ENV[ 'SEND_HUB_NUMBER' ] )
11
+ end
12
+
13
+ context 'pass' do
14
+
15
+ it 'passes if it can connect to SendHub' do
16
+ expect( checker.status ).to be_nil
17
+ end
18
+ end
19
+
20
+ context 'fail' do
21
+
22
+ it 'fails if it receives nil' do
23
+ expect( @send_hub ).to receive( :get_contacts ).and_return( nil )
24
+ expect( checker.status ).to_not be_nil
25
+ end
26
+
27
+ it 'fails if there is an exception' do
28
+ expect( @send_hub ).to receive( :get_contacts ).and_raise( 'This is only a test' )
29
+ expect( checker.status ).to_not be_nil
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'stripe'
3
2
 
4
3
  describe StatusCat::Checkers::Stripe do
@@ -7,7 +6,7 @@ describe StatusCat::Checkers::Stripe do
7
6
  let( :email ) { 'foo@bar.com' }
8
7
 
9
8
  before( :each ) do
10
- Stripe::Account.stub( :retrieve ).and_return( @stripe = double( Stripe::Account ) )
9
+ allow( Stripe::Account ).to receive( :retrieve ).and_return( @stripe = double( Stripe::Account ) )
11
10
  end
12
11
 
13
12
  it_should_behave_like 'a status checker'
@@ -40,5 +39,4 @@ describe StatusCat::Checkers::Stripe do
40
39
  expect( @stripe ).to receive( :email ).and_return( email )
41
40
  expect( checker.value ).to eql( email )
42
41
  end
43
-
44
42
  end
@@ -0,0 +1,33 @@
1
+ describe StatusCat::Checkers::Twilio do
2
+
3
+ let( :checker ) { StatusCat::Checkers::Twilio.new.freeze }
4
+
5
+ it_should_behave_like 'a status checker'
6
+
7
+ describe '#initialize' do
8
+
9
+ it 'sets the value' do
10
+ expect( checker.value ).to eql( ENV[ 'TWILIO_SID' ] )
11
+ end
12
+
13
+ context 'pass' do
14
+
15
+ it 'passes if it can connect to Twilio' do
16
+ expect( checker.status ).to be_nil
17
+ end
18
+ end
19
+
20
+ context 'fail' do
21
+
22
+ it 'fails if it receives nil' do
23
+ expect( @twilio_messages ).to receive( :total ).and_return( nil )
24
+ expect( checker.status ).to_not be_nil
25
+ end
26
+
27
+ it 'fails if there is an exception' do
28
+ expect( @twilio_messages ).to receive( :total ).and_raise( 'This is only a test' )
29
+ expect( checker.status ).to_not be_nil
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,80 +1,82 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::Config do
4
2
 
5
3
  let( :config ) { StatusCat::Config.instance }
6
4
 
7
5
  it 'is a singleton' do
8
- config.should be( StatusCat::Config.instance )
6
+ expect( config ).to be( StatusCat::Config.instance )
9
7
  end
10
8
 
11
9
  describe 'attributes' do
12
10
 
13
11
  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 )
12
+ config.authenticate = config.authenticate
13
+ expect( config.authenticate ).to eql( config.authenticate )
17
14
  end
18
15
 
19
16
  it 'has an #authorize accessor' do
20
- config.authorize = StatusCat::Config::NIL_PROC
21
17
  config.authorize = config.authorize
22
- config.authorize.should eql( config.authorize )
18
+ expect( config.authorize ).to eql( config.authorize )
23
19
  end
24
20
 
25
21
  it 'has an #enabled accessor' do
26
- config.enabled.should_not be_nil
22
+ expect( config.enabled ).to_not be_nil
27
23
  config.enabled = config.enabled
28
- config.enabled.should eql( config.enabled )
24
+ expect( config.enabled ).to eql( config.enabled )
29
25
  end
30
26
 
31
27
  it 'has a #from accessor' do
32
- config.from.should_not be_nil
28
+ expect( config.from ).to_not be_nil
33
29
  config.from = config.from
34
- config.from.should eql( config.from )
30
+ expect( config.from ).to eql( config.from )
35
31
  end
36
32
 
37
33
  it 'has a #layout accessor' do
38
- config.layout.should_not be_nil
34
+ expect( config.layout ).to_not be_nil
39
35
  config.layout = config.layout
40
- config.layout.should eql( config.layout )
36
+ expect( config.layout ).to eql( config.layout )
41
37
  end
42
38
 
43
39
  it 'has a #noreply accessor' do
44
- config.noreply.should_not be_nil
40
+ expect( config.noreply ).to_not be_nil
45
41
  config.noreply = config.noreply
46
- config.noreply.should eql( config.noreply )
42
+ expect( config.noreply ).to eql( config.noreply )
47
43
  end
48
44
 
49
45
  it 'has a #to accessor' do
50
- config.to.should_not be_nil
46
+ expect( config.to ).to_not be_nil
51
47
  config.to = config.to
52
- config.to.should eql( config.to )
48
+ expect( config.to ).to eql( config.to )
53
49
  end
54
50
 
55
51
  it 'has an #subject accessor' do
56
- config.subject.should_not be_nil
52
+ expect( config.subject ).to_not be_nil
57
53
  config.subject = config.subject
58
- config.subject.should eql( config.subject )
54
+ expect( config.subject ).to eql( config.subject )
59
55
  end
60
-
61
56
  end
62
57
 
63
58
  describe '#initialize' do
64
59
 
65
60
  it 'defaults the #enabled list to all StatusCat::Checkers::Base subclasses' do
66
61
  descendants = StatusCat::Checkers::Base.descendants
67
- StatusCat::Checkers::Base.should_receive( :descendants ).and_return( descendants )
62
+ expect( StatusCat::Checkers::Base ).to receive( :descendants ).and_return( descendants )
68
63
 
69
64
  config.enabled = nil
70
65
  config.send( :initialize )
71
- config.enabled.should_not be_nil
66
+ expect( config.enabled ).to_not be_nil
72
67
  end
73
-
74
68
  end
75
69
 
76
70
  describe '#authenticate_with' do
77
71
 
72
+ before( :each ) do
73
+ @authenticate = config.authenticate
74
+ end
75
+
76
+ after( :each ) do
77
+ config.authenticate = @authenticate
78
+ end
79
+
78
80
  it 'accepts a block' do
79
81
  config.authenticate = nil
80
82
  config.authenticate_with do
@@ -91,18 +93,25 @@ describe StatusCat::Config do
91
93
  end
92
94
 
93
95
  instance_eval( &config.authenticate_with )
94
- expect( @test ).to be_true
96
+ expect( @test ).to be( true )
95
97
  end
96
98
 
97
99
  it 'returns a nil proc if none has been set' do
98
100
  config.authenticate = nil
99
101
  instance_eval( &config.authenticate_with )
100
102
  end
101
-
102
103
  end
103
104
 
104
105
  describe '#authorize_with' do
105
106
 
107
+ before( :each ) do
108
+ @authorize = config.authorize
109
+ end
110
+
111
+ after( :each ) do
112
+ config.authorize = @authorize
113
+ end
114
+
106
115
  it 'accepts a block' do
107
116
  config.authorize = nil
108
117
  config.authorize_with do
@@ -119,15 +128,13 @@ describe StatusCat::Config do
119
128
  end
120
129
 
121
130
  instance_eval( &config.authorize_with )
122
- expect( @test ).to be_true
131
+ expect( @test ).to be( true )
123
132
  end
124
133
 
125
134
  it 'returns a nil proc if none has been set' do
126
135
  config.authorize = nil
127
136
  instance_eval( &config.authorize_with )
128
137
  end
129
-
130
138
  end
131
-
132
139
  end
133
140