nagiosplugin 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Guardfile CHANGED
@@ -1,6 +1,12 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
+ guard 'rspec', :cli => '--color' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
4
10
  guard 'cucumber' do
5
11
  watch(%r{^lib/.+$}) { 'features' }
6
12
  watch(%r{^features/.+\.feature$})
data/Rakefile CHANGED
@@ -5,4 +5,10 @@ Cucumber::Rake::Task.new(:features) do |t|
5
5
  t.cucumber_opts = "--format pretty"
6
6
  end
7
7
 
8
+ require "rspec/core/rake_task"
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.rspec_opts = %w[--color]
11
+ t.pattern = "./spec/**/*_spec.rb"
12
+ end
13
+
8
14
  task :default => :features
@@ -1,3 +1,3 @@
1
1
  module NagiosPlugin
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/nagiosplugin.gemspec CHANGED
@@ -19,5 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "rake"
20
20
  s.add_development_dependency "cucumber"
21
21
  s.add_development_dependency "aruba"
22
- s.add_development_dependency 'guard-cucumber'
22
+ s.add_development_dependency "guard-cucumber"
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "guard-rspec"
23
25
  end
@@ -0,0 +1,59 @@
1
+ require "spec_helper"
2
+
3
+ describe NagiosPlugin::Plugin do
4
+ before :each do
5
+ @plugin = NagiosPlugin::Plugin.new
6
+ end
7
+
8
+ it "should be unknown when not checked yet" do
9
+ @plugin.status.should eql(:unknown)
10
+ end
11
+
12
+ [
13
+ {:critical? => false, :warning? => false, :status => :ok },
14
+ {:critical? => false, :warning? => true, :status => :warning },
15
+ {:critical? => true, :warning? => false, :status => :critical},
16
+ {:critical? => true, :warning? => true, :status => :critical}
17
+ ].each do |result|
18
+ it "should be #{result[:status].to_s} if checked so" do
19
+ @plugin.stub(:critical?).and_return(result[:critical?])
20
+ @plugin.stub(:warning?).and_return(result[:warning?])
21
+ @plugin.check
22
+ @plugin.status.should eql(result[:status])
23
+ end
24
+ end
25
+
26
+ it "should raise when all checks return false" do
27
+ [:critical?, :warning?, :ok?].each do |m|
28
+ @plugin.stub(m).and_return(false)
29
+ end
30
+ lambda { @plugin.check }.should raise_error(NagiosPlugin::PluginError)
31
+ @plugin.status.should eql(:unknown)
32
+ end
33
+
34
+
35
+ it "should raise if check methods are undefined" do
36
+ lambda { @plugin.check }.should raise_error(NoMethodError)
37
+ @plugin.status.should eql(:unknown)
38
+
39
+ @plugin.instance_exec { def critical?; false end }
40
+ lambda { @plugin.check }.should raise_error(NoMethodError)
41
+ @plugin.status.should eql(:unknown)
42
+
43
+ @plugin.instance_exec { def warning?; false end }
44
+ lambda { @plugin.check }.should_not raise_error(NoMethodError)
45
+ @plugin.status.should_not eql(:unknown)
46
+ end
47
+
48
+ it "should also represent the status as exit code" do
49
+ {
50
+ :ok => 0,
51
+ :warning => 1,
52
+ :critical => 2,
53
+ :unknown => 3
54
+ }.each_pair do |status,code|
55
+ @plugin.stub(:status).and_return(status)
56
+ @plugin.code.should eql(code)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1 @@
1
+ require "nagiosplugin"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagiosplugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-31 00:00:00.000000000Z
12
+ date: 2012-01-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70208300095840 !ruby/object:Gem::Requirement
16
+ requirement: &70254492064300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70208300095840
24
+ version_requirements: *70254492064300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cucumber
27
- requirement: &70208300095100 !ruby/object:Gem::Requirement
27
+ requirement: &70254492063540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70208300095100
35
+ version_requirements: *70254492063540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aruba
38
- requirement: &70208300094540 !ruby/object:Gem::Requirement
38
+ requirement: &70254492062620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70208300094540
46
+ version_requirements: *70254492062620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-cucumber
49
- requirement: &70208300093900 !ruby/object:Gem::Requirement
49
+ requirement: &70254492062020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,29 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70208300093900
57
+ version_requirements: *70254492062020
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70254492061520 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70254492061520
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: &70254492060940 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70254492060940
58
80
  description: Yet another framework for writing Nagios Plugins
59
81
  email:
60
82
  - bjoernalbers@googlemail.com
@@ -76,6 +98,8 @@ files:
76
98
  - lib/nagiosplugin/plugin.rb
77
99
  - lib/nagiosplugin/version.rb
78
100
  - nagiosplugin.gemspec
101
+ - spec/nagiosplugin/plugin_spec.rb
102
+ - spec/spec_helper.rb
79
103
  homepage: https://github.com/bjoernalbers/nagiosplugin
80
104
  licenses: []
81
105
  post_install_message:
@@ -90,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
114
  version: '0'
91
115
  segments:
92
116
  - 0
93
- hash: 3492650550251720727
117
+ hash: -1632254141614995050
94
118
  required_rubygems_version: !ruby/object:Gem::Requirement
95
119
  none: false
96
120
  requirements:
@@ -99,14 +123,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
123
  version: '0'
100
124
  segments:
101
125
  - 0
102
- hash: 3492650550251720727
126
+ hash: -1632254141614995050
103
127
  requirements: []
104
128
  rubyforge_project:
105
129
  rubygems_version: 1.8.10
106
130
  signing_key:
107
131
  specification_version: 3
108
- summary: nagiosplugin-0.0.5
132
+ summary: nagiosplugin-0.0.6
109
133
  test_files:
110
134
  - features/plugin_output.feature
111
135
  - features/steps/dev_steps.rb
112
136
  - features/support/env.rb
137
+ - spec/nagiosplugin/plugin_spec.rb
138
+ - spec/spec_helper.rb