updawg 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+ require 'hpricot'
3
+
4
+ describe Updawg::ResultSet do
5
+ before(:each) do
6
+ @results = Updawg::ResultSet.new
7
+ @results << Updawg::Result.new('One', :pass, 'everything is okay')
8
+ end
9
+
10
+ it 'should be successful if all checks passed' do
11
+ @results.should be_success
12
+ @results.should_not be_warning
13
+ @results.should_not be_error
14
+ end
15
+
16
+ it 'should be warning if at least one check is a warning' do
17
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
18
+ @results.should be_warning
19
+ @results.should_not be_success
20
+ @results.should_not be_error
21
+ end
22
+
23
+ it 'should be error if at least one check is an error' do
24
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
25
+ @results << Updawg::Result.new('Three', :error, 'oh no!')
26
+ @results.should be_error
27
+ @results.should_not be_success
28
+ @results.should_not be_warning
29
+ end
30
+
31
+ describe '#errors' do
32
+ it 'should return array of failed results' do
33
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
34
+ @results << (error = Updawg::Result.new('Three', :error, 'oh no!'))
35
+ @results.errors.should == [error]
36
+ end
37
+ end
38
+
39
+ describe '#warnings' do
40
+ it 'should return array of warning results' do
41
+ @results << (warn = Updawg::Result.new('Two', :warning, 'oh no!'))
42
+ @results << Updawg::Result.new('Three', :error, 'oh no!')
43
+ @results.warnings.should == [warn]
44
+ end
45
+ end
46
+
47
+ describe '#to_html' do
48
+ it 'should build a table with the status in the class' do
49
+ tag = Hpricot(@results.to_html)/'table.pass'
50
+ tag.should_not be_empty
51
+
52
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
53
+ tag = Hpricot(@results.to_html)/'table.warning'
54
+ tag.should_not be_empty
55
+
56
+ @results << Updawg::Result.new('Three', :error, 'oh no!')
57
+ tag = Hpricot(@results.to_html)/'table.error'
58
+ tag.should_not be_empty
59
+ end
60
+
61
+ it 'should have a row for each test' do
62
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
63
+ @results << Updawg::Result.new('Three', :error, 'oh no!')
64
+
65
+ rows = Hpricot(@results.to_html)/'tr'
66
+ rows.length.should == 3
67
+ end
68
+
69
+ it 'should include the name of the check' do
70
+ row = Hpricot(@results.to_html)/'tr'
71
+ (row/'td.name').text.should == 'One'
72
+ end
73
+
74
+ it 'should include the message for the check regardless of status' do
75
+ row = Hpricot(@results.to_html)/'tr:last'
76
+ (row/'td.message').text.should == 'everything is okay'
77
+
78
+ @results << Updawg::Result.new('Two', :warning, 'oops')
79
+ row = Hpricot(@results.to_html)/'tr:last'
80
+ (row/'td.message').text.should == 'oops'
81
+
82
+ @results << Updawg::Result.new('Three', :error, 'fml')
83
+ row = Hpricot(@results.to_html)/'tr:last'
84
+ (row/'td.message').text.should == 'fml'
85
+ end
86
+
87
+ it 'should include the status text for the check' do
88
+ row = Hpricot(@results.to_html)/'tr'
89
+ (row/'td.status').text.should == 'PASS'
90
+ end
91
+ end
92
+
93
+ describe '#to_text' do
94
+ it 'should have one result one per line' do
95
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
96
+ @results.to_text.should match(/PASS\t.*\nWARNING\t.*\n/)
97
+ end
98
+ end
99
+
100
+ describe '#nagios_report!' do
101
+ it 'should exit with status 0 if there were no errors' do
102
+ @results.should_receive(:exit).with(0)
103
+ @results.nagios_report!(StringIO.new)
104
+ end
105
+
106
+ it 'should exit with status 1 if there were warnings but no errors' do
107
+ @results << Updawg::Result.new('Two', :warning, 'oh no!')
108
+ @results.should_receive(:exit).with(1)
109
+ @results.nagios_report!(StringIO.new)
110
+ end
111
+
112
+ it 'should exit with status 2 if there were errors' do
113
+ @results << Updawg::Result.new('Two', :error, 'oh no!')
114
+ @results.should_receive(:exit).with(2)
115
+ @results.nagios_report!(StringIO.new)
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,59 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Updawg do
4
+ it 'should create a configuration object' do
5
+ Updawg.configuration.should be_instance_of(Updawg::Configuration)
6
+ end
7
+
8
+ describe "configuration" do
9
+ before(:each) do
10
+ Updawg.configuration = Updawg::Configuration.new
11
+ end
12
+
13
+ describe 'by default' do
14
+ it 'should set error_text to ERROR' do
15
+ Updawg.configuration.error_text.should == 'ERROR'
16
+ end
17
+
18
+ it 'should set warning_text to WARNING' do
19
+ Updawg.configuration.warning_text.should == 'WARNING'
20
+ end
21
+
22
+ it 'should set success_text to PASS' do
23
+ Updawg.configuration.success_text.should == 'PASS'
24
+ end
25
+ end
26
+
27
+ it 'should preserve configuration options between configure calls' do
28
+ Updawg.configure{|c| c.error_text = 'test'}
29
+ Updawg.configure
30
+ Updawg.configuration.error_text.should == 'test'
31
+ end
32
+
33
+ it 'should allow configuration for error_text' do
34
+ Updawg.configure {|c| c.error_text = 'test'}
35
+ Updawg.configuration.error_text.should == 'test'
36
+ end
37
+
38
+ it 'should allow configuration for error_text' do
39
+ Updawg.configure {|c| c.error_text = 'test'}
40
+ Updawg.configuration.error_text.should == 'test'
41
+ end
42
+
43
+ it 'should allow configuration for success_text' do
44
+ Updawg.configure {|c| c.success_text = 'test'}
45
+ Updawg.configuration.success_text.should == 'test'
46
+ end
47
+ end
48
+
49
+ describe '#monitor' do
50
+ it 'should create a monitor and instance_eval the block' do
51
+ block = lambda { self.class.should == Updawg::Monitor }
52
+ Updawg.monitor(&block).should be_instance_of(Updawg::Monitor)
53
+ end
54
+
55
+ it 'should return a new monitor with each call' do
56
+ Updawg.monitor{}.should_not === Updawg.monitor{}
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{updawg}
8
+ s.version = "0.3.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Matt Griffin"]
12
+ s.date = %q{2011-03-23}
13
+ s.email = %q{matt@griffinonline.org}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "CHANGELOG",
22
+ "Gemfile",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/updawg.rb",
28
+ "lib/updawg/checks.rb",
29
+ "lib/updawg/checks/check.rb",
30
+ "lib/updawg/checks/deviation_check.rb",
31
+ "lib/updawg/checks/threshold_check.rb",
32
+ "lib/updawg/monitor.rb",
33
+ "lib/updawg/results.rb",
34
+ "spec/spec.opts",
35
+ "spec/spec_helper.rb",
36
+ "spec/updawg/checks/check_spec.rb",
37
+ "spec/updawg/checks/deviation_check_spec.rb",
38
+ "spec/updawg/checks/threshold_check_spec.rb",
39
+ "spec/updawg/monitor_spec.rb",
40
+ "spec/updawg/results_spec.rb",
41
+ "spec/updawg_spec.rb",
42
+ "updawg.gemspec"
43
+ ]
44
+ s.homepage = %q{http://github.com/Viximo/updawg}
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = %q{1.3.7}
47
+ s.summary = %q{A simple way to see what's up, dawg (and what's not.)}
48
+ s.test_files = [
49
+ "spec/spec.opts",
50
+ "spec/spec_helper.rb",
51
+ "spec/updawg/checks/check_spec.rb",
52
+ "spec/updawg/checks/deviation_check_spec.rb",
53
+ "spec/updawg/checks/threshold_check_spec.rb",
54
+ "spec/updawg/monitor_spec.rb",
55
+ "spec/updawg/results_spec.rb",
56
+ "spec/updawg_spec.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<builder>, ["~> 2.1"])
65
+ s.add_runtime_dependency(%q<aggregate>, [">= 0"])
66
+ s.add_development_dependency(%q<rspec>, ["~> 1.3"])
67
+ s.add_development_dependency(%q<hpricot>, ["~> 0.8"])
68
+ else
69
+ s.add_dependency(%q<builder>, ["~> 2.1"])
70
+ s.add_dependency(%q<aggregate>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
72
+ s.add_dependency(%q<hpricot>, ["~> 0.8"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<builder>, ["~> 2.1"])
76
+ s.add_dependency(%q<aggregate>, [">= 0"])
77
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
78
+ s.add_dependency(%q<hpricot>, ["~> 0.8"])
79
+ end
80
+ end
81
+
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: updawg
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 5
10
+ version: 0.3.5
11
+ platform: ruby
12
+ authors:
13
+ - Matt Griffin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-28 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ name: builder
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 1
31
+ segments:
32
+ - 2
33
+ - 1
34
+ version: "2.1"
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ type: :runtime
39
+ name: aggregate
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ type: :development
53
+ name: rspec
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 9
60
+ segments:
61
+ - 1
62
+ - 3
63
+ version: "1.3"
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ prerelease: false
67
+ type: :development
68
+ name: hpricot
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 27
75
+ segments:
76
+ - 0
77
+ - 8
78
+ version: "0.8"
79
+ requirement: *id004
80
+ description:
81
+ email: matt@griffinonline.org
82
+ executables: []
83
+
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE
88
+ - README.rdoc
89
+ files:
90
+ - .document
91
+ - .gitignore
92
+ - CHANGELOG
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - lib/updawg.rb
99
+ - lib/updawg/checks.rb
100
+ - lib/updawg/checks/check.rb
101
+ - lib/updawg/checks/deviation_check.rb
102
+ - lib/updawg/checks/threshold_check.rb
103
+ - lib/updawg/monitor.rb
104
+ - lib/updawg/results.rb
105
+ - spec/spec.opts
106
+ - spec/spec_helper.rb
107
+ - spec/updawg/checks/check_spec.rb
108
+ - spec/updawg/checks/deviation_check_spec.rb
109
+ - spec/updawg/checks/threshold_check_spec.rb
110
+ - spec/updawg/monitor_spec.rb
111
+ - spec/updawg/results_spec.rb
112
+ - spec/updawg_spec.rb
113
+ - updawg.gemspec
114
+ has_rdoc: true
115
+ homepage: http://github.com/Viximo/updawg
116
+ licenses: []
117
+
118
+ post_install_message:
119
+ rdoc_options: []
120
+
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ hash: 3
138
+ segments:
139
+ - 0
140
+ version: "0"
141
+ requirements: []
142
+
143
+ rubyforge_project:
144
+ rubygems_version: 1.3.7
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: A simple way to see what's up, dawg (and what's not.)
148
+ test_files:
149
+ - spec/spec.opts
150
+ - spec/spec_helper.rb
151
+ - spec/updawg/checks/check_spec.rb
152
+ - spec/updawg/checks/deviation_check_spec.rb
153
+ - spec/updawg/checks/threshold_check_spec.rb
154
+ - spec/updawg/monitor_spec.rb
155
+ - spec/updawg/results_spec.rb
156
+ - spec/updawg_spec.rb