cucumber-nagios 0.6.8 → 0.7.0
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.
- data/AUTHORS +16 -0
- data/HACKING +13 -0
- data/README.md +34 -0
- data/TODO +3 -0
- data/bin/cucumber-nagios-gen +6 -3
- data/lib/cucumber-nagios.rb +1 -7
- data/lib/{generators/project/features/support → cucumber/formatter}/nagios.rb +0 -0
- data/lib/cucumber/nagios.rb +17 -0
- data/lib/cucumber/nagios/command.rb +225 -0
- data/lib/cucumber/nagios/steps.rb +10 -0
- data/lib/cucumber/nagios/steps/amqp_steps.rb +59 -0
- data/lib/{generators/project/features → cucumber/nagios}/steps/benchmark_steps.rb +0 -0
- data/lib/cucumber/nagios/steps/command_steps.rb +80 -0
- data/lib/cucumber/nagios/steps/dns_steps.rb +17 -0
- data/lib/cucumber/nagios/steps/file_steps.rb +120 -0
- data/lib/cucumber/nagios/steps/ping_steps.rb +13 -0
- data/lib/{generators/project/features → cucumber/nagios}/steps/result_steps.rb +0 -0
- data/lib/{generators/project/features → cucumber/nagios}/steps/ssh_steps.rb +0 -0
- data/lib/{generators/project/features → cucumber/nagios}/steps/webrat_steps.rb +0 -0
- data/lib/{generators/project/features → cucumber/nagios}/support/env.rb +4 -7
- data/lib/cucumber/nagios/version.rb +5 -0
- data/lib/generators/project/Gemfile +4 -1
- metadata +130 -37
- data/Rakefile +0 -41
- data/features/creating.feature +0 -11
- data/features/installing.feature +0 -11
- data/features/steps/creating_steps.rb +0 -23
- data/features/steps/installing_steps.rb +0 -28
- data/features/steps/using_steps.rb +0 -31
- data/features/support/silent_system.rb +0 -4
- data/features/using.feature +0 -21
data/AUTHORS
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Author
|
2
|
+
------
|
3
|
+
|
4
|
+
Lindsay Holmwood <lindsay@holmwood.id.au>
|
5
|
+
|
6
|
+
Contributors
|
7
|
+
------------
|
8
|
+
|
9
|
+
Morgan Christiansson <morgan@mog.se>
|
10
|
+
Martin Englund <martin.englund@sun.com>
|
11
|
+
Adam Jacob <adam@opscode.com>
|
12
|
+
Juri Rischel Jensen <juri@fab-it.dk>
|
13
|
+
Gareth Rushgrove <gareth@morethanseven.net>
|
14
|
+
Jesse Newland <jesse@jnewland.com>
|
15
|
+
|
16
|
+
Portions of cucumber-nagios contain code originally contributed to Chef (http://github.com/opscode/chef)
|
data/HACKING
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Running tests
|
2
|
+
=============
|
3
|
+
|
4
|
+
Make sure you have the rspec and Cucumber gems installed.
|
5
|
+
|
6
|
+
Cucumber features live under features/. They cover the basics of installing,
|
7
|
+
creating projects, and running cucumber-nagios.
|
8
|
+
|
9
|
+
Run the features with:
|
10
|
+
|
11
|
+
$ rake cucumber
|
12
|
+
|
13
|
+
They can take a while as they freeze in the dependencies a bunch of times.
|
data/README.md
CHANGED
@@ -189,7 +189,24 @@ need fine grained testing:
|
|
189
189
|
When I follow "Contact"
|
190
190
|
Then the elapsed time should be less than 7 seconds
|
191
191
|
|
192
|
+
AMQP Message Queues
|
193
|
+
===================
|
192
194
|
|
195
|
+
You can test for various conditions on an AMQP message queue.
|
196
|
+
|
197
|
+
Feature: github.com
|
198
|
+
To make sure the rest of the system is in order
|
199
|
+
All our message queues must not be backed up
|
200
|
+
|
201
|
+
Scenario: test queue 2
|
202
|
+
Given I have a AMQP server on rabbit.github.com
|
203
|
+
And I want to check on the fork queue
|
204
|
+
Then it should have less than 400 messages
|
205
|
+
Then it should have at least 5 consumers
|
206
|
+
Then it should have less than 50 messages per consumer
|
207
|
+
|
208
|
+
This has been tested using RabbitMQ but uses the amqp gem which should support
|
209
|
+
other backends. See features/amqp_steps.rb for all the available steps.
|
193
210
|
|
194
211
|
Quirks
|
195
212
|
======
|
@@ -204,6 +221,23 @@ i.e. if you try fetching a page on a server that is down, or the page returns
|
|
204
221
|
a 404, the exception raised by Mechanize just gets treated by Cucumber as a
|
205
222
|
test failure.
|
206
223
|
|
224
|
+
Using the Steps in another Cucumber suite
|
225
|
+
=========================================
|
226
|
+
|
227
|
+
If you want to use the steps defined in cucumber-nagios elsewhere, you can
|
228
|
+
require the steps in `features/support/env` like so:
|
229
|
+
|
230
|
+
# All
|
231
|
+
require 'cucumber/nagios/steps'
|
232
|
+
|
233
|
+
# Or one by one
|
234
|
+
require 'cucumber/nagios/steps/ssh'
|
235
|
+
require 'cucumber/nagios/steps/ping'
|
236
|
+
|
237
|
+
Using the Formatter in another Cucumber suite
|
238
|
+
=============================================
|
239
|
+
|
240
|
+
cucumber --format Cucumber::Formatter::Nagios features/foo.feature
|
207
241
|
|
208
242
|
Version control
|
209
243
|
===============
|
data/TODO
ADDED
data/bin/cucumber-nagios-gen
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'templater'
|
5
|
-
require 'cucumber
|
5
|
+
require 'cucumber/nagios'
|
6
6
|
|
7
7
|
module CucumberNagiosGenerators
|
8
8
|
|
@@ -23,8 +23,11 @@ module CucumberNagiosGenerators
|
|
23
23
|
|
24
24
|
file '.gitignore', '.gitignore'
|
25
25
|
file '.bzrignore', '.bzrignore'
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
directory :steps, ::File.join(File.dirname(__FILE__), '..', 'lib', 'cucumber', 'nagios', 'steps'), 'features/steps'
|
28
|
+
directory :features, ::File.join(File.dirname(__FILE__), '..', 'lib', 'cucumber', 'nagios', 'support'), 'features/support'
|
29
|
+
|
30
|
+
glob!
|
28
31
|
|
29
32
|
end
|
30
33
|
|
data/lib/cucumber-nagios.rb
CHANGED
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Nagios
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'cucumber/nagios/version'
|
8
|
+
require 'cucumber/nagios/command'
|
9
|
+
require 'net/ssh'
|
10
|
+
require 'webrat'
|
11
|
+
require 'mq'
|
12
|
+
rescue LoadError => e
|
13
|
+
dep = e.message.split.last
|
14
|
+
puts "You don't appear to have #{dep} installed."
|
15
|
+
puts "Perhaps run `gem bundle` or `gem install #{dep}`?"
|
16
|
+
exit 2
|
17
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# Portions of this file originally from Chef (github.com/opscode/chef)
|
25
|
+
|
26
|
+
require 'tmpdir'
|
27
|
+
require 'fcntl'
|
28
|
+
require 'etc'
|
29
|
+
require 'io/wait'
|
30
|
+
|
31
|
+
module Cucumber
|
32
|
+
module Nagios
|
33
|
+
module Command
|
34
|
+
|
35
|
+
# This is taken directly from Ara T Howard's Open4 library, and then
|
36
|
+
# modified to suit the needs of Chef. Any bugs here are most likely
|
37
|
+
# my own, and not Ara's.
|
38
|
+
#
|
39
|
+
# The original appears in external/open4.rb in its unmodified form.
|
40
|
+
#
|
41
|
+
# Thanks Ara!
|
42
|
+
def popen4(cmd, args={}, &b)
|
43
|
+
|
44
|
+
# Waitlast - this is magic.
|
45
|
+
#
|
46
|
+
# Do we wait for the child process to die before we yield
|
47
|
+
# to the block, or after? That is the magic of waitlast.
|
48
|
+
#
|
49
|
+
# By default, we are waiting before we yield the block.
|
50
|
+
args[:waitlast] ||= false
|
51
|
+
|
52
|
+
args[:user] ||= nil
|
53
|
+
unless args[:user].kind_of?(Integer)
|
54
|
+
args[:user] = Etc.getpwnam(args[:user]).uid if args[:user]
|
55
|
+
end
|
56
|
+
args[:group] ||= nil
|
57
|
+
unless args[:group].kind_of?(Integer)
|
58
|
+
args[:group] = Etc.getgrnam(args[:group]).gid if args[:group]
|
59
|
+
end
|
60
|
+
args[:environment] ||= {}
|
61
|
+
|
62
|
+
# Default on C locale so parsing commands output can be done
|
63
|
+
# independently of the node's default locale.
|
64
|
+
# "LC_ALL" could be set to nil, in which case we also must ignore it.
|
65
|
+
unless args[:environment].has_key?("LC_ALL")
|
66
|
+
args[:environment]["LC_ALL"] = "C"
|
67
|
+
end
|
68
|
+
|
69
|
+
pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe
|
70
|
+
|
71
|
+
verbose = $VERBOSE
|
72
|
+
begin
|
73
|
+
$VERBOSE = nil
|
74
|
+
ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
75
|
+
|
76
|
+
cid = fork {
|
77
|
+
pw.last.close
|
78
|
+
STDIN.reopen pw.first
|
79
|
+
pw.first.close
|
80
|
+
|
81
|
+
pr.first.close
|
82
|
+
STDOUT.reopen pr.last
|
83
|
+
pr.last.close
|
84
|
+
|
85
|
+
pe.first.close
|
86
|
+
STDERR.reopen pe.last
|
87
|
+
pe.last.close
|
88
|
+
|
89
|
+
STDOUT.sync = STDERR.sync = true
|
90
|
+
|
91
|
+
if args[:group]
|
92
|
+
Process.egid = args[:group]
|
93
|
+
Process.gid = args[:group]
|
94
|
+
end
|
95
|
+
|
96
|
+
if args[:user]
|
97
|
+
Process.euid = args[:user]
|
98
|
+
Process.uid = args[:user]
|
99
|
+
end
|
100
|
+
|
101
|
+
args[:environment].each do |key,value|
|
102
|
+
ENV[key] = value
|
103
|
+
end
|
104
|
+
|
105
|
+
if args[:umask]
|
106
|
+
umask = ((args[:umask].respond_to?(:oct) ? args[:umask].oct : args[:umask].to_i) & 007777)
|
107
|
+
File.umask(umask)
|
108
|
+
end
|
109
|
+
|
110
|
+
begin
|
111
|
+
if cmd.kind_of?(Array)
|
112
|
+
exec(*cmd)
|
113
|
+
else
|
114
|
+
exec(cmd)
|
115
|
+
end
|
116
|
+
raise 'forty-two'
|
117
|
+
rescue Exception => e
|
118
|
+
Marshal.dump(e, ps.last)
|
119
|
+
ps.last.flush
|
120
|
+
end
|
121
|
+
ps.last.close unless (ps.last.closed?)
|
122
|
+
exit!
|
123
|
+
}
|
124
|
+
ensure
|
125
|
+
$VERBOSE = verbose
|
126
|
+
end
|
127
|
+
|
128
|
+
[pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
|
129
|
+
|
130
|
+
begin
|
131
|
+
e = Marshal.load ps.first
|
132
|
+
raise(Exception === e ? e : "unknown failure!")
|
133
|
+
rescue EOFError # If we get an EOF error, then the exec was successful
|
134
|
+
42
|
135
|
+
ensure
|
136
|
+
ps.first.close
|
137
|
+
end
|
138
|
+
|
139
|
+
pw.last.sync = true
|
140
|
+
|
141
|
+
pi = [pw.last, pr.first, pe.first]
|
142
|
+
|
143
|
+
if b
|
144
|
+
begin
|
145
|
+
if args[:waitlast]
|
146
|
+
b[cid, *pi]
|
147
|
+
Process.waitpid2(cid).last
|
148
|
+
else
|
149
|
+
# This took some doing.
|
150
|
+
# The trick here is to close STDIN
|
151
|
+
# Then set our end of the childs pipes to be O_NONBLOCK
|
152
|
+
# Then wait for the child to die, which means any IO it
|
153
|
+
# wants to do must be done - it's dead. If it isn't,
|
154
|
+
# it's because something totally skanky is happening,
|
155
|
+
# and we don't care.
|
156
|
+
o = StringIO.new
|
157
|
+
e = StringIO.new
|
158
|
+
|
159
|
+
pi[0].close
|
160
|
+
|
161
|
+
stdout = pi[1]
|
162
|
+
stderr = pi[2]
|
163
|
+
|
164
|
+
stdout.sync = true
|
165
|
+
stderr.sync = true
|
166
|
+
|
167
|
+
stdout.fcntl(Fcntl::F_SETFL, pi[1].fcntl(Fcntl::F_GETFL) | Fcntl::O_NONBLOCK)
|
168
|
+
stderr.fcntl(Fcntl::F_SETFL, pi[2].fcntl(Fcntl::F_GETFL) | Fcntl::O_NONBLOCK)
|
169
|
+
|
170
|
+
stdout_finished = false
|
171
|
+
stderr_finished = false
|
172
|
+
|
173
|
+
results = nil
|
174
|
+
|
175
|
+
while !stdout_finished || !stderr_finished
|
176
|
+
begin
|
177
|
+
channels_to_watch = []
|
178
|
+
channels_to_watch << stdout if !stdout_finished
|
179
|
+
channels_to_watch << stderr if !stderr_finished
|
180
|
+
ready = IO.select(channels_to_watch, nil, nil, 1.0)
|
181
|
+
rescue Errno::EAGAIN
|
182
|
+
ensure
|
183
|
+
results = Process.waitpid2(cid, Process::WNOHANG)
|
184
|
+
if results
|
185
|
+
stdout_finished = true
|
186
|
+
stderr_finished = true
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
if ready && ready.first.include?(stdout)
|
191
|
+
line = results ? stdout.gets(nil) : stdout.gets
|
192
|
+
if line
|
193
|
+
o.write(line)
|
194
|
+
else
|
195
|
+
stdout_finished = true
|
196
|
+
end
|
197
|
+
end
|
198
|
+
if ready && ready.first.include?(stderr)
|
199
|
+
line = results ? stderr.gets(nil) : stderr.gets
|
200
|
+
if line
|
201
|
+
e.write(line)
|
202
|
+
else
|
203
|
+
stderr_finished = true
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
results = Process.waitpid2(cid) unless results
|
208
|
+
o.rewind
|
209
|
+
e.rewind
|
210
|
+
b[cid, pi[0], o, e]
|
211
|
+
results.last
|
212
|
+
end
|
213
|
+
ensure
|
214
|
+
pi.each{|fd| fd.close unless fd.closed?}
|
215
|
+
end
|
216
|
+
else
|
217
|
+
[cid, pw.last, pr.first, pe.first]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
module_function :popen4
|
222
|
+
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'cucumber/nagios'
|
2
|
+
require 'cucumber/nagios/steps/amqp_steps'
|
3
|
+
require 'cucumber/nagios/steps/benchmark_steps'
|
4
|
+
require 'cucumber/nagios/steps/command_steps'
|
5
|
+
require 'cucumber/nagios/steps/dns_steps'
|
6
|
+
require 'cucumber/nagios/steps/file_steps'
|
7
|
+
require 'cucumber/nagios/steps/ping_steps'
|
8
|
+
require 'cucumber/nagios/steps/result_steps'
|
9
|
+
require 'cucumber/nagios/steps/ssh_steps'
|
10
|
+
require 'cucumber/nagios/steps/webrat_steps'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'mq'
|
2
|
+
|
3
|
+
# simple function to get at the number of messages on a queue and the
|
4
|
+
# number of consumers using it and store them in variables for later use
|
5
|
+
def get_details_of_queue(queue, host)
|
6
|
+
AMQP.start(:host => host) do
|
7
|
+
jobs = MQ.queue(queue)
|
8
|
+
jobs.status do |msgs, cns|
|
9
|
+
@messages = msgs
|
10
|
+
@count = cns
|
11
|
+
end
|
12
|
+
AMQP.stop{ EM.stop }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# set up some defaults so we can compare numbers without
|
17
|
+
# raising exceptions
|
18
|
+
Before do
|
19
|
+
@messages = 0
|
20
|
+
@consumers = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
# Step definitions for testing various conditions on the queue
|
24
|
+
Given /I have a AMQP server on (.+)$/ do |host|
|
25
|
+
@host = host
|
26
|
+
end
|
27
|
+
|
28
|
+
And /I want to check on the (\w+) queue$/ do |queue|
|
29
|
+
get_details_of_queue(queue, @host)
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /it should have less than (\d+) messages per consumer$/ do |messages|
|
33
|
+
@consumers.should > 0
|
34
|
+
messages.to_i.should < @messages/@consumers
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /it should have less than (\d+) messages$/ do |messages|
|
38
|
+
@messages.should < messages.to_i
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /it should have at least (\d+) messages$/ do |messages|
|
42
|
+
@messages.should >= messages.to_i
|
43
|
+
end
|
44
|
+
|
45
|
+
Then /it should have more than (\d+) messages$/ do |messages|
|
46
|
+
@messages.should > messages.to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
Then /It should have more than (\d+) consumers$/ do |consumers|
|
50
|
+
@consumers.should > consumers.to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
Then /It should have less than (\d+) consumers$/ do |consumers|
|
54
|
+
@consumers.should < consumers.to_i
|
55
|
+
end
|
56
|
+
|
57
|
+
Then /It should have (\d+) consumers$/ do |consumers|
|
58
|
+
@consumers.should == consumers.to_i
|
59
|
+
end
|
File without changes
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# Portions of this file originally from Chef (github.com/opscode/chef)
|
25
|
+
|
26
|
+
When /^I run '(.+)'$/ do |cmd|
|
27
|
+
status = Cucumber::Nagios::Command.popen4(cmd) do |p, i, o, e|
|
28
|
+
@stdout = o.gets(nil)
|
29
|
+
@stderr = e.gets(nil)
|
30
|
+
end
|
31
|
+
@status = status
|
32
|
+
end
|
33
|
+
|
34
|
+
###
|
35
|
+
# Then
|
36
|
+
###
|
37
|
+
Then /^it should exit '(.+)'$/ do |exit_code|
|
38
|
+
begin
|
39
|
+
@status.exitstatus.should eql(exit_code.to_i)
|
40
|
+
rescue
|
41
|
+
print_output
|
42
|
+
raise
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Then /^it should exit from being signaled$/ do
|
47
|
+
begin
|
48
|
+
@status.signaled?.should == true
|
49
|
+
rescue
|
50
|
+
print_output
|
51
|
+
raise
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def print_output
|
56
|
+
puts "--- run stdout:"
|
57
|
+
puts @stdout
|
58
|
+
puts "--- run stderr:"
|
59
|
+
puts @stderr
|
60
|
+
end
|
61
|
+
|
62
|
+
# Then 'stdout' should have 'foo'
|
63
|
+
Then /^'(.+)' should have '(.+)'$/ do |which, to_match|
|
64
|
+
self.instance_variable_get("@#{which}".to_sym).should match(/#{to_match}/m)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Then 'stderr' should not have 'foo'
|
68
|
+
Then /^'(.+)' should not have '(.+)'$/ do |which, to_match|
|
69
|
+
self.instance_variable_get("@#{which}".to_sym).should_not match(/#{to_match}/m)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Then 'my dog ate my homework' should appear on 'stdout' '5' times
|
73
|
+
Then /^'(.+)' should appear on '(.+)' '(.+)' times$/ do |to_match, which, count|
|
74
|
+
seen_count = 0
|
75
|
+
self.instance_variable_get("@#{which}".to_sym).split("\n").each do |line|
|
76
|
+
seen_count += 1 if line =~ /#{to_match}/
|
77
|
+
end
|
78
|
+
seen_count.should == count.to_i
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
When /^I lookup "([^\"]*)"$/ do |name|
|
2
|
+
s = Socket.getaddrinfo(name, nil)
|
3
|
+
@ip = s[0][3]
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^I reverse lookup "([^\"]*)"$/ do |ip|
|
7
|
+
s = Socket.getaddrinfo(ip, nil)
|
8
|
+
@name = s[0][2]
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^the name should resolve to "([^\"]*)"$/ do |ip|
|
12
|
+
@ip.should == ip
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^the IP should resolve to "([^\"]*)"$/ do |name|
|
16
|
+
@name.downcase.should == name.downcase
|
17
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# Portions of this file originally from Chef (github.com/opscode/chef)
|
25
|
+
|
26
|
+
require 'etc'
|
27
|
+
|
28
|
+
###
|
29
|
+
# Given
|
30
|
+
###
|
31
|
+
|
32
|
+
Given /^we have an empty file named '(.+)'$/ do |filename|
|
33
|
+
filename = File.new(filename, 'w')
|
34
|
+
filename.close
|
35
|
+
end
|
36
|
+
|
37
|
+
Given /^we have the atime\/mtime of '(.+)'$/ do |filename|
|
38
|
+
@mtime = File.mtime(filename)
|
39
|
+
@atime = File.atime(filename)
|
40
|
+
end
|
41
|
+
|
42
|
+
####
|
43
|
+
# Then
|
44
|
+
####
|
45
|
+
|
46
|
+
Then /^a file named '(.+)' should exist$/ do |filename|
|
47
|
+
File.exists?(filename).should be(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
Then /^a file named '(.+)' should not exist$/ do |filename|
|
51
|
+
File.exists?(filename).should be(false)
|
52
|
+
end
|
53
|
+
|
54
|
+
Then /^'(.+)' should exist and raise error when copying$/ do |filename|
|
55
|
+
File.exists?(filename).should be(true)
|
56
|
+
lambda{copy(filename, filename + "_copy", false)}.should raise_error()
|
57
|
+
File.delete(filename)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
Then /^the (.)time of '(.+)' should be different$/ do |time_type, filename|
|
62
|
+
case time_type
|
63
|
+
when "m"
|
64
|
+
current_mtime = File.mtime(filename)
|
65
|
+
current_mtime.should_not == @mtime
|
66
|
+
when "a"
|
67
|
+
current_atime = File.atime(filename)
|
68
|
+
current_atime.should_not == @atime
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Then /^a file named '(.+)' should contain '(.+)'$/ do |filename, contents|
|
73
|
+
file = IO.read(filename)
|
74
|
+
file.should =~ /#{contents}/m
|
75
|
+
end
|
76
|
+
|
77
|
+
Then /^a file named '(.+)' should contain '(.+)' only '(.+)' time(?:s)?$/ do |filename, string, count|
|
78
|
+
seen_count = 0
|
79
|
+
IO.foreach(filename) do |line|
|
80
|
+
if line =~ /#{string}/
|
81
|
+
seen_count += 1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
seen_count.should == count.to_i
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /^the file named '(.+)' should be owned by '(.+)'$/ do |filename, owner|
|
88
|
+
uid = Etc.getpwnam(owner).uid
|
89
|
+
cstats = File.stat(filename)
|
90
|
+
cstats.uid.should == uid
|
91
|
+
end
|
92
|
+
|
93
|
+
Then /^the file named '(.+)' should have mode '(.+)'$/ do |filename, expected_mode|
|
94
|
+
cstats = File.stat(filename)
|
95
|
+
(cstats.mode & 007777).should == octal_mode(expected_mode)
|
96
|
+
end
|
97
|
+
|
98
|
+
def octal_mode(mode)
|
99
|
+
((mode.respond_to?(:oct) ? mode.oct : mode.to_i) & 007777)
|
100
|
+
end
|
101
|
+
|
102
|
+
Then /^a directory named '(.+)' should exist$/ do |dir|
|
103
|
+
File.directory?(dir).should be(true)
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^a directory named '(.+)' should not exist$/ do |dir|
|
107
|
+
File.directory?(dir).should be(false)
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^the directory named '(.+)' should be owned by '(.+)'$/ do |dirname, owner|
|
111
|
+
uid = Etc.getpwnam(owner).uid
|
112
|
+
cstats = File.stat(File.join(tmpdir, dirname))
|
113
|
+
cstats.uid.should == uid
|
114
|
+
end
|
115
|
+
|
116
|
+
Then /^the directory named '(.+)' should have mode '(.+)'$/ do |dirname, expected_mode|
|
117
|
+
cstats = File.stat(dirname)
|
118
|
+
(cstats.mode & 007777).should == octal_mode(expected_mode)
|
119
|
+
end
|
120
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# TODO: this has only been tested on Solaris, so it should be changed to
|
2
|
+
# handle other operating systems too
|
3
|
+
When /^I ping "([^\"]*)"$/ do |host|
|
4
|
+
@result = system("ping #{host} > /dev/null 2>&1")
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^it should respond$/ do
|
8
|
+
@result.should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^it should not respond$/ do
|
12
|
+
@result.should be_false
|
13
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'cucumber/nagios'
|
2
|
+
|
3
|
+
#For standalone execution
|
2
4
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'webrat'
|
5
5
|
require 'webrat/adapters/mechanize'
|
6
|
-
require 'net/ssh'
|
7
6
|
|
8
7
|
class ResponseHelper
|
9
8
|
def response
|
@@ -14,6 +13,4 @@ end
|
|
14
13
|
World do
|
15
14
|
ResponseHelper.new
|
16
15
|
Webrat::Session.new(Webrat::MechanizeAdapter.new)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-nagios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Lindsay Holmwood
|
@@ -9,39 +14,121 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-20 00:00:00 +10:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: templater
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 1.0.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: rake
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 8
|
44
|
+
- 3
|
33
45
|
version: 0.8.3
|
34
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: bundler08
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - "="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 8
|
58
|
+
- 5
|
43
59
|
version: 0.8.5
|
44
|
-
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: cucumber
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
- 6
|
72
|
+
- 1
|
73
|
+
version: 0.6.1
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: net-ssh
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 2
|
85
|
+
- 0
|
86
|
+
- 18
|
87
|
+
version: 2.0.18
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: webrat
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
- 7
|
100
|
+
- 0
|
101
|
+
version: 0.7.0
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id006
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: amqp
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
- 6
|
114
|
+
- 7
|
115
|
+
version: 0.6.7
|
116
|
+
type: :runtime
|
117
|
+
version_requirements: *id007
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: rspec
|
120
|
+
prerelease: false
|
121
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
segments:
|
126
|
+
- 1
|
127
|
+
- 3
|
128
|
+
- 0
|
129
|
+
version: 1.3.0
|
130
|
+
type: :runtime
|
131
|
+
version_requirements: *id008
|
45
132
|
description: cucumber-nagios lets you write high-level behavioural tests for your web applications and Unix infrastructure that can be plugged into Nagios
|
46
133
|
email: lindsay@holmwood.id.au
|
47
134
|
executables:
|
@@ -52,31 +139,35 @@ extra_rdoc_files: []
|
|
52
139
|
|
53
140
|
files:
|
54
141
|
- bin/cucumber-nagios-gen
|
142
|
+
- lib/cucumber/formatter/nagios.rb
|
143
|
+
- lib/cucumber/nagios/command.rb
|
144
|
+
- lib/cucumber/nagios/steps/amqp_steps.rb
|
145
|
+
- lib/cucumber/nagios/steps/benchmark_steps.rb
|
146
|
+
- lib/cucumber/nagios/steps/command_steps.rb
|
147
|
+
- lib/cucumber/nagios/steps/dns_steps.rb
|
148
|
+
- lib/cucumber/nagios/steps/file_steps.rb
|
149
|
+
- lib/cucumber/nagios/steps/ping_steps.rb
|
150
|
+
- lib/cucumber/nagios/steps/result_steps.rb
|
151
|
+
- lib/cucumber/nagios/steps/ssh_steps.rb
|
152
|
+
- lib/cucumber/nagios/steps/webrat_steps.rb
|
153
|
+
- lib/cucumber/nagios/steps.rb
|
154
|
+
- lib/cucumber/nagios/support/env.rb
|
155
|
+
- lib/cucumber/nagios/version.rb
|
156
|
+
- lib/cucumber/nagios.rb
|
55
157
|
- lib/cucumber-nagios.rb
|
56
|
-
- lib/generators/project/Gemfile
|
57
|
-
- lib/generators/project/features/steps/benchmark_steps.rb
|
58
|
-
- lib/generators/project/features/steps/ssh_steps.rb
|
59
|
-
- lib/generators/project/features/steps/result_steps.rb
|
60
|
-
- lib/generators/project/features/steps/webrat_steps.rb
|
61
|
-
- lib/generators/project/features/support/env.rb
|
62
|
-
- lib/generators/project/features/support/nagios.rb
|
63
158
|
- lib/generators/project/bin/cucumber-nagios
|
64
159
|
- lib/generators/project/bin/cucumber-nagios-gen
|
65
|
-
- lib/generators/project
|
66
|
-
- lib/generators/project
|
160
|
+
- lib/generators/project/Gemfile
|
161
|
+
- lib/generators/project/lib/generators/feature/%feature_name%.feature
|
162
|
+
- lib/generators/project/lib/generators/feature/%feature_name%_steps.rb
|
67
163
|
- lib/generators/project/README
|
68
164
|
- LICENSE
|
69
165
|
- README.md
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
- features/steps/installing_steps.rb
|
76
|
-
- features/steps/using_steps.rb
|
77
|
-
- features/steps/creating_steps.rb
|
78
|
-
- features/creating.feature
|
79
|
-
- features/installing.feature
|
166
|
+
- AUTHORS
|
167
|
+
- HACKING
|
168
|
+
- TODO
|
169
|
+
- lib/generators/project/.gitignore
|
170
|
+
- lib/generators/project/.bzrignore
|
80
171
|
has_rdoc: true
|
81
172
|
homepage: http://auxesis.github.com/cucumber-nagios/
|
82
173
|
licenses: []
|
@@ -90,18 +181,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
181
|
requirements:
|
91
182
|
- - ">="
|
92
183
|
- !ruby/object:Gem::Version
|
184
|
+
segments:
|
185
|
+
- 0
|
93
186
|
version: "0"
|
94
|
-
version:
|
95
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
188
|
requirements:
|
97
189
|
- - ">="
|
98
190
|
- !ruby/object:Gem::Version
|
191
|
+
segments:
|
192
|
+
- 0
|
99
193
|
version: "0"
|
100
|
-
version:
|
101
194
|
requirements: []
|
102
195
|
|
103
196
|
rubyforge_project: cucumber-nagios
|
104
|
-
rubygems_version: 1.3.
|
197
|
+
rubygems_version: 1.3.6
|
105
198
|
signing_key:
|
106
199
|
specification_version: 3
|
107
200
|
summary: systems testing plugin for Nagios using Cucumber/Webrat/Mechanize/net-ssh
|
data/Rakefile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'cucumber/rake/task'
|
8
|
-
|
9
|
-
Cucumber::Rake::Task.new do |t|
|
10
|
-
t.cucumber_opts = "--require features/"
|
11
|
-
end
|
12
|
-
rescue LoadError
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
desc "build gem"
|
17
|
-
task :build do
|
18
|
-
system("gem build cucumber-nagios.gemspec")
|
19
|
-
|
20
|
-
FileUtils.mkdir_p('pkg')
|
21
|
-
puts
|
22
|
-
Dir.glob("cucumber-nagios-*.gem").each do |gem|
|
23
|
-
dest = File.join('pkg', gem)
|
24
|
-
FileUtils.mv(gem, dest)
|
25
|
-
puts "New gem in #{dest}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "push gem"
|
30
|
-
task :push do
|
31
|
-
filenames = Dir.glob("pkg/*.gem")
|
32
|
-
filenames_with_times = filenames.map do |filename|
|
33
|
-
[filename, File.mtime(filename)]
|
34
|
-
end
|
35
|
-
|
36
|
-
oldest = filenames_with_times.sort_by { |tuple| tuple.last }.last
|
37
|
-
oldest_filename = oldest.first
|
38
|
-
|
39
|
-
command = "gem push #{oldest_filename}"
|
40
|
-
system(command)
|
41
|
-
end
|
data/features/creating.feature
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Feature: Creating new project
|
2
|
-
To test websites
|
3
|
-
A cucumber-nagios projert
|
4
|
-
Must be created
|
5
|
-
|
6
|
-
Scenario: Create a project
|
7
|
-
Given cucumber-nagios is installed
|
8
|
-
When I create a new project called "great-website-tests"
|
9
|
-
And I freeze in dependencies
|
10
|
-
Then my gems directory should be populated
|
11
|
-
|
data/features/installing.feature
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Feature: Installation
|
2
|
-
To set up a cucumber-nagios project
|
3
|
-
A user
|
4
|
-
Must be able to install the gem
|
5
|
-
|
6
|
-
Scenario: Installing the gem
|
7
|
-
When I build the gem
|
8
|
-
And I install the latest gem
|
9
|
-
Then I should have cucumber-nagios-gen on my path
|
10
|
-
And I can generate a new project
|
11
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
Given /^cucumber\-nagios is installed$/ do
|
2
|
-
When 'I build the gem'
|
3
|
-
And 'I install the latest gem'
|
4
|
-
Then 'I should have cucumber-nagios-gen on my path'
|
5
|
-
end
|
6
|
-
|
7
|
-
When /^I create a new project called "([^\"]*)"$/ do |project_name|
|
8
|
-
@project_name = project_name
|
9
|
-
FileUtils.rm_rf("/tmp/#{@project_name}")
|
10
|
-
|
11
|
-
silent_system("cd /tmp ; cucumber-nagios-gen project #{@project_name}").should be_true
|
12
|
-
end
|
13
|
-
|
14
|
-
When /^I freeze in dependencies$/ do
|
15
|
-
@project_name.should_not be_nil
|
16
|
-
silent_system("cd /tmp/#{@project_name} ; gem bundle").should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
Then /^my gems directory should be populated$/ do
|
20
|
-
@project_name.should_not be_nil
|
21
|
-
Dir.glob("/tmp/#{@project_name}/vendor/gems/*").size.should > 0
|
22
|
-
end
|
23
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
When /^I build the gem$/ do
|
2
|
-
project_root = File.join(File.dirname(__FILE__), '..', '..')
|
3
|
-
rakefile = File.join(project_root, 'Rakefile')
|
4
|
-
File.exist?(rakefile).should be_true
|
5
|
-
|
6
|
-
silent_system("rake -f #{rakefile} build").should be_true
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I install the latest gem$/ do
|
10
|
-
project_root = File.join(File.dirname(__FILE__), '..', '..')
|
11
|
-
pkg_dir = File.join(project_root, 'pkg')
|
12
|
-
pkg = File.expand_path(Dir.glob(File.join(pkg_dir, '*.gem')).last)
|
13
|
-
|
14
|
-
silent_system("gem install #{pkg} 2>&1 > /dev/null").should be_true
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^I should have cucumber\-nagios\-gen on my path$/ do
|
18
|
-
silent_system("which cucumber-nagios-gen").should be_true
|
19
|
-
end
|
20
|
-
|
21
|
-
Then /^I can generate a new project$/ do
|
22
|
-
testproj = "testproj-#{Time.now.to_i}"
|
23
|
-
FileUtils.rm_rf("/tmp/#{testproj}")
|
24
|
-
|
25
|
-
silent_system("cd /tmp ; cucumber-nagios-gen project #{testproj}").should be_true
|
26
|
-
File.exists?("/tmp/#{testproj}").should be_true
|
27
|
-
end
|
28
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
Given /^a project called "([^\"]*)" is created and frozen$/ do |project_name|
|
2
|
-
@project_name = project_name
|
3
|
-
Given 'cucumber-nagios is installed'
|
4
|
-
When "I create a new project called \"#{@project_name}\""
|
5
|
-
And 'I freeze in dependencies'
|
6
|
-
Then 'my gems directory should be populated'
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I generate a new feature called "([^\"]*)" for "([^\"]*)"$/ do |feature, site|
|
10
|
-
silent_system("cd /tmp/#{@project_name} ; bin/cucumber-nagios-gen feature #{site} #{feature}")
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^a feature file should exist for "([^\"]*)" on "([^\"]*)"$/ do |feature, site|
|
14
|
-
File.exists?("/tmp/#{@project_name}/features/#{site}/#{feature}.feature").should be_true
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^the "([^\"]*)" feature on "([^\"]*)" should exit cleanly$/ do |feature, site|
|
18
|
-
silent_system("cd /tmp/#{@project_name} ; bin/cucumber-nagios features/#{site}/#{feature}.feature").should be_true
|
19
|
-
end
|
20
|
-
|
21
|
-
Then /^the "([^\"]*)" feature on "([^\"]*)" should not exit cleanly$/ do |feature, site|
|
22
|
-
silent_system("cd /tmp/#{@project_name} ; bin/cucumber-nagios features/#{site}/#{feature}.feature").should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
When /^the "([^\"]*)" feature on "([^\"]*)" checks for something preposterous$/ do |feature, site|
|
26
|
-
file_name = "/tmp/#{@project_name}/features/#{site}/#{feature}.feature"
|
27
|
-
File.open(file_name,'a') do |file|
|
28
|
-
file << " Then I should see \"supercalifragilisticexpialidocious\""
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
data/features/using.feature
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Feature: Using features
|
2
|
-
To test websites
|
3
|
-
A cucumber feature
|
4
|
-
Must be created
|
5
|
-
|
6
|
-
Scenario: Create a feature
|
7
|
-
Given cucumber-nagios is installed
|
8
|
-
And a project called "more-great-tests" is created and frozen
|
9
|
-
When I generate a new feature called "login" for "github.com"
|
10
|
-
Then a feature file should exist for "login" on "github.com"
|
11
|
-
|
12
|
-
Scenario: Run a successful feature
|
13
|
-
Given a project called "passing-features" is created and frozen
|
14
|
-
When I generate a new feature called "homepage" for "github.com"
|
15
|
-
Then the "homepage" feature on "github.com" should exit cleanly
|
16
|
-
|
17
|
-
Scenario: Run a failing feature
|
18
|
-
Given a project called "failing-features" is created and frozen
|
19
|
-
When I generate a new feature called "profile" for "github.com"
|
20
|
-
And the "profile" feature on "github.com" checks for something preposterous
|
21
|
-
Then the "profile" feature on "github.com" should not exit cleanly
|