auxesis-cucumber-nagios 0.2.8 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,20 +16,20 @@ As Bradley Taylor [put it](http://bradley.is/post/82649218/testing-dash-metrics-
16
16
  Setting up a project
17
17
  ====================
18
18
 
19
- To set up a standalone cucumber-nagios project, run:
19
+ To set up a standalone `cucumber-nagios` project, run:
20
20
 
21
21
  cucumber-nagios-gen project <project-name>
22
22
 
23
- This will spit out a bunch of files in the directory specified as <project-name>.
23
+ This will spit out a bunch of files in the directory specified as `<project-name>`.
24
24
 
25
- Check the README within this directory for specific instructions for managing
25
+ Check the `README` within this directory for specific instructions for managing
26
26
  the project.
27
27
 
28
28
 
29
29
  Writing Features
30
30
  ================
31
31
 
32
- Within your project, I suggest you put your features under under features/$fqdn/$name.feature.
32
+ Within your project, I suggest you put your features under under `features/$fqdn/$name.feature`.
33
33
 
34
34
  You'll want to have a read of the Cucumber documentation, however
35
35
  your tests will look something like this:
@@ -45,10 +45,10 @@ your tests will look something like this:
45
45
  Then I should see "www.wikipedia.org"
46
46
 
47
47
  There's a collection of steps that will cover most of the things you'll be
48
- testing for in features/steps/webrat_steps.rb.
48
+ testing for in `features/steps/webrat_steps.rb`.
49
49
 
50
50
  You can write custom steps for testing specific output and behaviour, e.g.
51
- in features/smh.com.au/smh.feature:
51
+ in `features/smh.com.au/smh.feature`:
52
52
 
53
53
  Feature: smh.com.au
54
54
  It should be up
@@ -60,7 +60,7 @@ in features/smh.com.au/smh.feature:
60
60
  And there should be a section named "Opinion"
61
61
 
62
62
  There aren't steps for "Then I should see site navigation", so you have to
63
- write one yourself. :-) In features/smh.com.au/steps/smh_steps.rb:
63
+ write one yourself. :-) In `features/smh.com.au/steps/smh_steps.rb`:
64
64
 
65
65
  Then /^I should see site navigation$/ do
66
66
  doc = Nokogiri::HTML(response.body.to_s)
@@ -70,7 +70,7 @@ write one yourself. :-) In features/smh.com.au/steps/smh_steps.rb:
70
70
  You can use Nokogiri for testing responses with XPath matchers and CSS
71
71
  selectors.
72
72
 
73
- I suggest you use bin/cucumber directly so you can get better feedback when
73
+ I suggest you use `bin/cucumber` directly so you can get better feedback when
74
74
  writing your tests:
75
75
 
76
76
  bin/cucumber --require bin/common.rb \
@@ -81,17 +81,17 @@ writing your tests:
81
81
  Running
82
82
  =======
83
83
 
84
- Invoke the cucumber feature with the cucumber-nagios script:
84
+ Invoke the Cucumber feature with the `cucumber-nagios` script:
85
85
 
86
86
  bin/cucumber-nagios features/smh.com.au/smh.feature
87
87
 
88
- cucumber-nagios can be run from anywhere:
88
+ `cucumber-nagios` can be run from anywhere:
89
89
 
90
90
  /path/to/bin/cucumber-nagios /path/to/features/smh/smh.feature
91
91
 
92
92
  It should return a standard Nagios-formatted response string:
93
93
 
94
- Critical: 0, Warning: 0, 2 okay | passed=2, failed=0.0, total=2
94
+ Critical: 0, Warning: 0, 2 okay | passed=2, failed=0, total=2
95
95
 
96
96
  Steps that fail will show up in the "Critical" total, and steps that pass
97
97
  show up in the "okay" total.
@@ -106,11 +106,11 @@ Caveats
106
106
  You may want to think about keeping to one scenario to a file, otherwise
107
107
  you'll get multiple lines of output for a test:
108
108
 
109
- Critical: 1, Warning: 0, 2 okay | value=2.000000;;;;
110
- Critical: 1, Warning: 0, 4 okay | value=4.000000;;;;
109
+ Critical: 1, Warning: 0, 2 okay | passed=2, failed=1, total=3
110
+ Critical: 1, Warning: 0, 4 okay | passed=4, failed=1, total=5
111
111
 
112
- I assume Nagios will only read the last line, so this might be an ok behaviour
113
- when you want to test for an aggregate of failures across a site.
112
+ That said, Nagios should only read the last line, so this might be an ok
113
+ behaviour when you want to test for an aggregate of failures across a site.
114
114
 
115
115
 
116
116
 
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Add '.rb' to work around a bug in IronRuby's File#dirname
3
- $:.unshift(File.dirname(__FILE__ + '.rb') + '/../lib') unless $:.include?(File.dirname(__FILE__ + '.rb') + '/../lib')
2
+ $: << File.dirname(__FILE__)
4
3
 
5
4
  begin
6
5
  require 'common'
@@ -1,26 +1,27 @@
1
- #!/bin/sh
1
+ #!/usr/bin/env ruby
2
2
 
3
- if [ "$#" != "1" ]; then
4
- echo "Usage: $0 <feature>"
5
- exit 99
6
- fi
3
+ unless ARGV[0]
4
+ puts "Usage: #{__FILE__} <feature>"
5
+ exit 99
6
+ end
7
7
 
8
- dirname=$(dirname $0)
9
- feature=$1
8
+ __DIR__ = File.expand_path(File.dirname(__FILE__))
10
9
 
11
- if [ ! -e "$feature" ]; then
12
- echo "Error: feature file doesn't exist!"
13
- exit 98
14
- fi
10
+ feature = ARGV[0]
11
+ unless File.exists?(feature)
12
+ feature = File.join(__DIR__, '..', 'features', ARGV[0])
13
+ end
15
14
 
16
- $dirname/cucumber --require $dirname/common.rb \
17
- --require features/ \
18
- --format Nagios::NagiosFormatter \
19
- $feature
20
- retval=$?
15
+ unless File.exist?(feature)
16
+ puts "Error: feature file doesn't exist!"
17
+ exit 98
18
+ end
19
+
20
+ command = "#{__DIR__}/cucumber"
21
+ command += " --require #{__DIR__}/common.rb"
22
+ command += " --require features/"
23
+ command += " --format Nagios::NagiosFormatter"
24
+ command += " #{feature}"
25
+
26
+ system(command) ? exit(0) : exit(2)
21
27
 
22
- if [ "$retval" -eq "1" ]; then
23
- exit 2
24
- else
25
- exit $retval
26
- fi
@@ -7,28 +7,35 @@ module CucumberNagiosGenerators
7
7
 
8
8
  extend Templater::Manifold
9
9
 
10
- class ProjectGenerator < Templater::Generator
10
+ # feature generator
11
+ class FeatureGenerator < Templater::Generator
11
12
  def self.source_root
12
- File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'project')
13
+ File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'feature')
13
14
  end
14
15
 
15
- def destination_root
16
- # takes :name from first_argument
17
- File.join(@destination_root, name)
18
- end
16
+ desc <<-DESC
17
+ Generate a cucumber feature. Takes a two arguments:
18
+ bin/cucumber-nagios-gen feature <site-name> <feature-name>
19
+ DESC
19
20
 
20
- desc "Generate a new self-contained cucumber-nagios project."
21
- first_argument :name, :required => true, :desc => "Project name"
21
+ first_argument :site, :required => true, :desc => "Site name"
22
+ second_argument :feature, :required => true, :desc => "Feature name"
22
23
 
23
- glob!
24
- #file :rakefile, 'Rakefile'
24
+ template :feature do |template|
25
+ template.source = "%feature_name%.feature"
26
+ template.destination = "features/#{site}/#{feature}.feature"
27
+ end
28
+
29
+ template :step do |template|
30
+ template.source = "%feature_name%_steps.rb"
31
+ template.destination = "features/#{site}/steps/#{feature}_steps.rb"
32
+ end
25
33
 
26
34
  end
27
35
 
28
- desc "Generate a cucumber-nagios project."
29
- add :project, ProjectGenerator
36
+ desc "Generators for a cucumber-nagios project"
37
+ add :feature, FeatureGenerator
30
38
 
31
39
  end
32
40
 
33
-
34
41
  CucumberNagiosGenerators.run_cli Dir.pwd, 'cucumber-nagios-gen', '0.1', ARGV
@@ -10,6 +10,10 @@ Then /^I should see an? (\w+) message$/ do |message_type|
10
10
  response.should have_xpath("//*[@class='#{message_type}']")
11
11
  end
12
12
 
13
+ Then /^the (.*) ?request should succeed/ do |_|
14
+ response.should be_successful
15
+ end
16
+
13
17
  Then /^the (.*) ?request should fail/ do |_|
14
18
  response.should_not be_successful
15
19
  end
@@ -0,0 +1,7 @@
1
+ Feature: <%= site %>
2
+ It should be up
3
+
4
+ Scenario: Visiting home page
5
+ When I go to http://<%= site %>
6
+ Then the request should succeed
7
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auxesis-cucumber-nagios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-04 00:00:00 -08:00
12
+ date: 2009-03-05 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,6 +61,8 @@ files:
61
61
  - LICENSE
62
62
  - README.md
63
63
  - Rakefile
64
+ - lib/generators/project/lib/generators/feature/%feature_name%.feature
65
+ - lib/generators/project/lib/generators/feature/%feature_name%_steps.rb
64
66
  has_rdoc: false
65
67
  homepage: http://holmwood.id.au/~lindsay/2009/02/23/web-app-integration-testing-for-sysadmins-with-cucumber-nagios/
66
68
  post_install_message: