diagnostics 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +4 -4
  2. data/.specification +0 -0
  3. data/Gemfile.lock +39 -0
  4. data/LICENSE +20 -0
  5. data/README.md +7 -0
  6. data/app/controllers/diagnostics_application_controller.rb +12 -0
  7. data/app/controllers/diagnostics_controller.rb +6 -0
  8. data/app/controllers/statuses_controller.rb +20 -0
  9. data/app/views/diagnostics/_check.html.erb +1 -0
  10. data/app/views/diagnostics/index.html.erb +22 -0
  11. data/app/views/layouts/diagnostics.html.erb +114 -0
  12. data/app/views/statuses/show.html.erb +15 -0
  13. data/config/routes.rb +6 -0
  14. data/diagnostics.gemspec +2 -2
  15. data/features/diagnostic_checks.feature +167 -0
  16. data/features/step_definitions/aruba.rb +5 -0
  17. data/features/support/env.rb +2 -0
  18. data/lib/diagnostics/check.rb +66 -0
  19. data/lib/diagnostics/data/attribute.rb +15 -0
  20. data/lib/diagnostics/data/elements.rb +40 -0
  21. data/lib/diagnostics/data/list.rb +15 -0
  22. data/lib/diagnostics/data/table.rb +47 -0
  23. data/lib/diagnostics/data/text.rb +15 -0
  24. data/lib/diagnostics/data_group.rb +37 -0
  25. data/lib/diagnostics/methods.rb +46 -0
  26. data/lib/diagnostics/version.rb +1 -1
  27. data/rails/init.rb +1 -0
  28. data/spec/diagnostics/check_spec.rb +78 -0
  29. data/spec/diagnostics/data/attribute_spec.rb +22 -0
  30. data/spec/diagnostics/data/list_spec.rb +22 -0
  31. data/spec/diagnostics/data/table_spec.rb +63 -0
  32. data/spec/diagnostics/data/text_spec.rb +22 -0
  33. data/spec/diagnostics/data_group_spec.rb +177 -0
  34. data/spec/diagnostics/methods_spec.rb +128 -0
  35. data/spec/diagnostics_spec.rb +11 -0
  36. data/spec/spec_helper.rb +13 -0
  37. data/spec_rails/rails2/Gemfile +13 -0
  38. data/spec_rails/rails2/Gemfile.lock +91 -0
  39. data/spec_rails/rails2/Rakefile +13 -0
  40. data/spec_rails/rails2/app_root/README +243 -0
  41. data/spec_rails/rails2/app_root/Rakefile +10 -0
  42. data/spec_rails/rails2/app_root/app/controllers/application_controller.rb +10 -0
  43. data/spec_rails/rails2/app_root/app/helpers/application_helper.rb +3 -0
  44. data/spec_rails/rails2/app_root/config/boot.rb +114 -0
  45. data/spec_rails/rails2/app_root/config/database.yml +25 -0
  46. data/spec_rails/rails2/app_root/config/environment.rb +45 -0
  47. data/spec_rails/rails2/app_root/config/environments/cucumber.rb +29 -0
  48. data/spec_rails/rails2/app_root/config/environments/development.rb +17 -0
  49. data/spec_rails/rails2/app_root/config/environments/production.rb +28 -0
  50. data/spec_rails/rails2/app_root/config/environments/test.rb +28 -0
  51. data/spec_rails/rails2/app_root/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec_rails/rails2/app_root/config/initializers/cookie_verification_secret.rb +7 -0
  53. data/spec_rails/rails2/app_root/config/initializers/inflections.rb +10 -0
  54. data/spec_rails/rails2/app_root/config/initializers/load_diagnostics.rb +2 -0
  55. data/spec_rails/rails2/app_root/config/initializers/mime_types.rb +5 -0
  56. data/spec_rails/rails2/app_root/config/initializers/new_rails_defaults.rb +21 -0
  57. data/spec_rails/rails2/app_root/config/initializers/session_store.rb +15 -0
  58. data/spec_rails/rails2/app_root/config/locales/en.yml +5 -0
  59. data/spec_rails/rails2/app_root/config/routes.rb +43 -0
  60. data/spec_rails/rails2/app_root/db/seeds.rb +7 -0
  61. data/spec_rails/rails2/app_root/doc/README_FOR_APP +2 -0
  62. data/spec_rails/rails2/app_root/lib/diagnostics/mysql_check.rb +18 -0
  63. data/spec_rails/rails2/app_root/lib/diagnostics/server_check.rb +4 -0
  64. data/spec_rails/rails2/app_root/lib/tasks/cucumber.rake +53 -0
  65. data/spec_rails/rails2/app_root/public/404.html +30 -0
  66. data/spec_rails/rails2/app_root/public/422.html +30 -0
  67. data/spec_rails/rails2/app_root/public/500.html +30 -0
  68. data/spec_rails/rails2/app_root/public/favicon.ico +0 -0
  69. data/spec_rails/rails2/app_root/public/images/rails.png +0 -0
  70. data/spec_rails/rails2/app_root/public/index.html +275 -0
  71. data/spec_rails/rails2/app_root/public/javascripts/application.js +2 -0
  72. data/spec_rails/rails2/app_root/public/javascripts/controls.js +963 -0
  73. data/spec_rails/rails2/app_root/public/javascripts/dragdrop.js +973 -0
  74. data/spec_rails/rails2/app_root/public/javascripts/effects.js +1128 -0
  75. data/spec_rails/rails2/app_root/public/javascripts/prototype.js +4320 -0
  76. data/spec_rails/rails2/app_root/public/robots.txt +5 -0
  77. data/spec_rails/rails2/app_root/script/about +4 -0
  78. data/spec_rails/rails2/app_root/script/console +3 -0
  79. data/spec_rails/rails2/app_root/script/cucumber +10 -0
  80. data/spec_rails/rails2/app_root/script/dbconsole +3 -0
  81. data/spec_rails/rails2/app_root/script/destroy +3 -0
  82. data/spec_rails/rails2/app_root/script/generate +3 -0
  83. data/spec_rails/rails2/app_root/script/performance/benchmarker +3 -0
  84. data/spec_rails/rails2/app_root/script/performance/profiler +3 -0
  85. data/spec_rails/rails2/app_root/script/plugin +3 -0
  86. data/spec_rails/rails2/app_root/script/runner +3 -0
  87. data/spec_rails/rails2/app_root/script/server +3 -0
  88. data/spec_rails/rails2/app_root/test/performance/browsing_test.rb +9 -0
  89. data/spec_rails/rails2/app_root/test/test_helper.rb +38 -0
  90. data/spec_rails/rails2/controllers/diagnostics_controller_spec.rb +12 -0
  91. data/spec_rails/rails2/controllers/statuses_controller_spec.rb +34 -0
  92. data/spec_rails/rails2/features/diagnostics_page.feature +34 -0
  93. data/spec_rails/rails2/features/status_page.feature +43 -0
  94. data/spec_rails/rails2/features/step_definitions/diagnostic_steps.rb +39 -0
  95. data/spec_rails/rails2/features/step_definitions/web_steps.rb +219 -0
  96. data/spec_rails/rails2/features/support/env.rb +61 -0
  97. data/spec_rails/rails2/features/support/hooks.rb +3 -0
  98. data/spec_rails/rails2/features/support/paths.rb +36 -0
  99. data/spec_rails/rails2/spec.opts +1 -0
  100. data/spec_rails/rails2/spec_helper.rb +4 -0
  101. data/spec_rails/rails3/Gemfile +0 -0
  102. metadata +119 -7
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Diagnostics
4
+ module Data
5
+ describe Text do
6
+ let(:text) { described_class.new('foo') }
7
+
8
+ describe '#plain' do
9
+ specify do
10
+ text.plain.should eq('foo')
11
+ end
12
+ end
13
+
14
+ describe '#html' do
15
+ specify do
16
+ text.html.should eq('<p>foo</p>')
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,177 @@
1
+ require 'spec_helper'
2
+
3
+ module Diagnostics
4
+ describe DataGroup do
5
+
6
+ describe '#attributes' do
7
+ context 'with no attributes set' do
8
+ it 'returns an empty array' do
9
+ subject.attributes.should eq([])
10
+ end
11
+ end
12
+
13
+ context 'given :plain format' do
14
+ let(:data_group) { create_data_group }
15
+
16
+ specify do
17
+ data_group.attributes(:plain).should eq(['a: 1', 'b: 2'])
18
+ end
19
+ end
20
+
21
+ context 'given :html format' do
22
+ let(:data_group) { create_data_group }
23
+
24
+ specify do
25
+ data_group.attributes(:html).should eq(
26
+ ['<strong>a:</strong> 1', '<strong>b:</strong> 2']
27
+ )
28
+ end
29
+ end
30
+
31
+ def create_data_group
32
+ data_group = subject
33
+ data_group['a'] = 1
34
+ data_group['b'] = 2
35
+ data_group
36
+ end
37
+ end
38
+
39
+ describe '#lists' do
40
+ context 'with no lists added' do
41
+ it 'returns an empty array' do
42
+ subject.lists.should eq([])
43
+ end
44
+ end
45
+
46
+ context 'given :plain format' do
47
+ let(:data_group) { create_data_group }
48
+
49
+ specify do
50
+ data_group.lists(:plain).should eq(
51
+ ["a\nb\nc", "1\n2\n3"]
52
+ )
53
+ end
54
+ end
55
+
56
+ context 'given :html format' do
57
+ let(:data_group) { create_data_group }
58
+
59
+ specify do
60
+ data_group.lists(:html).should eq(
61
+ ['a<br />b<br />c', '1<br />2<br />3']
62
+ )
63
+ end
64
+ end
65
+
66
+ def create_data_group
67
+ data_group = subject
68
+ data_group << ['a', 'b', 'c']
69
+ data_group << [1, 2, 3]
70
+ data_group
71
+ end
72
+ end
73
+
74
+ describe '#texts' do
75
+ context 'with no texts added' do
76
+ it 'returns an empty array' do
77
+ subject.texts.should eq([])
78
+ end
79
+ end
80
+
81
+ context 'given :plain format' do
82
+ let(:data_group) { create_data_group }
83
+
84
+ specify do
85
+ data_group.texts(:plain).should eq(['a', 'b'])
86
+ end
87
+ end
88
+
89
+ context 'given :html format' do
90
+ let(:data_group) { create_data_group }
91
+
92
+ specify do
93
+ data_group.texts(:html).should eq(
94
+ ['<p>a</p>', '<p>b</p>']
95
+ )
96
+ end
97
+ end
98
+
99
+ def create_data_group
100
+ data_group = subject
101
+ data_group << 'a'
102
+ data_group << 'b'
103
+ data_group
104
+ end
105
+ end
106
+
107
+ describe '#tables' do
108
+ context 'with no texts added' do
109
+ it 'returns an empty array' do
110
+ subject.tables.should eq([])
111
+ end
112
+ end
113
+
114
+ context 'given :html format' do
115
+ let(:data_group) { create_data_group }
116
+
117
+ specify do
118
+ data_group.tables(:html).should eq(
119
+ [
120
+ '<table>' \
121
+ '<tr>' \
122
+ '<th>heading 1</th>' \
123
+ '<th>heading 2</th>' \
124
+ '</tr>' \
125
+ '<tr>' \
126
+ '<td>1</td>' \
127
+ '<td>3</td>' \
128
+ '</tr>' \
129
+ '<tr>' \
130
+ '<td>2</td>' \
131
+ '<td></td>' \
132
+ '</tr>' \
133
+ '</table>' \
134
+ ]
135
+ )
136
+ end
137
+ end
138
+
139
+ def create_data_group
140
+ data_group = subject
141
+ data_group << { 'heading 1' => [1,2],
142
+ 'heading 2' => [3, nil] }
143
+ data_group
144
+ end
145
+ end
146
+
147
+ describe '#[]=' do
148
+ it 'adds an instance of Data::Attribute' do
149
+ data_group = subject
150
+ data_group['key'] = 'value'
151
+ data_group.should have(1).attributes
152
+ data_group.attributes[0].should be_an_instance_of(Data::Attribute)
153
+ end
154
+ end
155
+
156
+ describe '#<<' do
157
+ context 'given an array' do
158
+ it 'adds an instance of Data::List' do
159
+ data_group = subject
160
+ data_group << [1,2,3]
161
+ data_group.should have(1).lists
162
+ data_group.lists[0].should be_an_instance_of(Data::List)
163
+ end
164
+ end
165
+
166
+ context 'given a string' do
167
+ it 'adds an instance of Data::Text' do
168
+ data_group = subject
169
+ data_group << "a string"
170
+ data_group.should have(1).texts
171
+ data_group.texts[0].should be_an_instance_of(Data::Text)
172
+ end
173
+ end
174
+ end
175
+
176
+ end
177
+ end
@@ -0,0 +1,128 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#diagnostic_checks' do
4
+ it 'defaults to an empty array' do
5
+ diagnostic_checks.should eq([])
6
+ end
7
+ end
8
+
9
+ describe '#diagnostic_check' do
10
+
11
+ context 'with block given' do
12
+ it 'adds a check' do
13
+ diagnostic_check(:foo) { }
14
+ diagnostic_checks.should have(1).check
15
+ diagnostic_checks.first.name.should eq(:foo)
16
+ end
17
+ end
18
+
19
+ context 'without block given' do
20
+ it 'finds the check' do
21
+ check = diagnostic_check(:foo) { }
22
+ diagnostic_check(:foo).should eq(check)
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ describe '#diagnostic_message' do
29
+
30
+ context 'with diagnostic_status returning :passed' do
31
+ before do
32
+ should_receive(:diagnostic_status).and_return(:passed)
33
+ end
34
+
35
+ specify do
36
+ diagnostic_message.should eq('All Systems Operational')
37
+ end
38
+ end
39
+
40
+ context 'with diagnostic_status returning :warning' do
41
+ before do
42
+ should_receive(:diagnostic_status).and_return(:warning)
43
+ end
44
+
45
+ specify do
46
+ diagnostic_message.should eq('Experiencing Issues')
47
+ end
48
+ end
49
+
50
+ context 'with diagnostic_status returning :failed' do
51
+ before do
52
+ should_receive(:diagnostic_status).and_return(:failed)
53
+ end
54
+
55
+ specify do
56
+ diagnostic_message.should eq('System Failure')
57
+ end
58
+ end
59
+
60
+ context 'with diagnostic_status returning :none' do
61
+ before do
62
+ should_receive(:diagnostic_status).and_return(:none)
63
+ end
64
+
65
+ specify do
66
+ diagnostic_message.should eq('No Diagnostic Checks Run')
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ describe '#diagnostic_status' do
73
+
74
+ context 'with all checks passing' do
75
+ before do
76
+ diagnostic_check(:foo) do |c|
77
+ c.passed { true }
78
+ end
79
+ diagnostic_check(:bar) do |c|
80
+ c.passed { true }
81
+ end
82
+ end
83
+
84
+ it 'returns :passed' do
85
+ diagnostic_status.should eq(:passed)
86
+ end
87
+ end
88
+
89
+ context 'with a check that failed' do
90
+ before do
91
+ diagnostic_check(:foo) do |c|
92
+ c.passed { true }
93
+ end
94
+ diagnostic_check(:zoo) do |c|
95
+ c.warning { true }
96
+ end
97
+ diagnostic_check(:bar) do |c|
98
+ c.failed { true }
99
+ end
100
+ end
101
+
102
+ it 'returns :failed' do
103
+ diagnostic_status.should eq(:failed)
104
+ end
105
+ end
106
+
107
+ context 'with a warning check' do
108
+ before do
109
+ diagnostic_check(:foo) do |c|
110
+ c.passed { true }
111
+ end
112
+ diagnostic_check(:bar) do |c|
113
+ c.warning { true }
114
+ end
115
+ end
116
+
117
+ it 'returns :warning' do
118
+ diagnostic_status.should eq(:warning)
119
+ end
120
+ end
121
+
122
+ context 'with no checks' do
123
+ it 'returns :none' do
124
+ diagnostic_status.should eq(:none)
125
+ end
126
+ end
127
+
128
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Diagnostics do
4
+
5
+ describe '.checks' do
6
+ it 'defaults to an empty array' do
7
+ described_class.checks.should eq([])
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'diagnostics'
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+
10
+ config.after do
11
+ diagnostic_checks.clear
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'rails', '2.3.10'
4
+ gem 'diagnostics', :path => '../..'
5
+
6
+ group :test do
7
+ gem 'rspec', '1.3.1'
8
+ gem 'rspec-rails', '1.3.3'
9
+ gem 'cucumber-rails'
10
+ gem 'database_cleaner'
11
+ gem 'capybara'
12
+ gem 'launchy'
13
+ end
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ diagnostics (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (2.3.10)
10
+ actionpack (= 2.3.10)
11
+ actionpack (2.3.10)
12
+ activesupport (= 2.3.10)
13
+ rack (~> 1.1.0)
14
+ activerecord (2.3.10)
15
+ activesupport (= 2.3.10)
16
+ activeresource (2.3.10)
17
+ activesupport (= 2.3.10)
18
+ activesupport (2.3.10)
19
+ builder (3.0.0)
20
+ capybara (0.4.0)
21
+ celerity (>= 0.7.9)
22
+ culerity (>= 0.2.4)
23
+ mime-types (>= 1.16)
24
+ nokogiri (>= 1.3.3)
25
+ rack (>= 1.0.0)
26
+ rack-test (>= 0.5.4)
27
+ selenium-webdriver (>= 0.0.27)
28
+ xpath (~> 0.1.2)
29
+ celerity (0.8.7)
30
+ childprocess (0.1.6)
31
+ ffi (~> 0.6.3)
32
+ configuration (1.2.0)
33
+ cucumber (0.10.0)
34
+ builder (>= 2.1.2)
35
+ diff-lcs (~> 1.1.2)
36
+ gherkin (~> 2.3.2)
37
+ json (~> 1.4.6)
38
+ term-ansicolor (~> 1.0.5)
39
+ cucumber-rails (0.3.2)
40
+ cucumber (>= 0.8.0)
41
+ culerity (0.2.14)
42
+ database_cleaner (0.6.0)
43
+ diff-lcs (1.1.2)
44
+ ffi (0.6.3)
45
+ rake (>= 0.8.7)
46
+ gherkin (2.3.3)
47
+ json (~> 1.4.6)
48
+ json (1.4.6)
49
+ json_pure (1.4.6)
50
+ launchy (0.3.7)
51
+ configuration (>= 0.0.5)
52
+ rake (>= 0.8.1)
53
+ mime-types (1.16)
54
+ nokogiri (1.4.4)
55
+ rack (1.1.0)
56
+ rack-test (0.5.7)
57
+ rack (>= 1.0)
58
+ rails (2.3.10)
59
+ actionmailer (= 2.3.10)
60
+ actionpack (= 2.3.10)
61
+ activerecord (= 2.3.10)
62
+ activeresource (= 2.3.10)
63
+ activesupport (= 2.3.10)
64
+ rake (>= 0.8.3)
65
+ rake (0.8.7)
66
+ rspec (1.3.1)
67
+ rspec-rails (1.3.3)
68
+ rack (>= 1.0.0)
69
+ rspec (= 1.3.1)
70
+ rubyzip (0.9.4)
71
+ selenium-webdriver (0.1.2)
72
+ childprocess (~> 0.1.5)
73
+ ffi (~> 0.6.3)
74
+ json_pure
75
+ rubyzip
76
+ term-ansicolor (1.0.5)
77
+ xpath (0.1.3)
78
+ nokogiri (~> 1.3)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ capybara
85
+ cucumber-rails
86
+ database_cleaner
87
+ diagnostics!
88
+ launchy
89
+ rails (= 2.3.10)
90
+ rspec (= 1.3.1)
91
+ rspec-rails (= 1.3.3)