Permalink
Browse files

done, pending docs

  • Loading branch information...
jnewland committed Jun 8, 2010
0 parents commit 9cb58dd96b13bb4846964e64a1cb0f5f6887442a
@@ -0,0 +1,5 @@
+README.rdoc
+lib/**/*.rb
+bin/*
+features/**/*.feature
+LICENSE
@@ -0,0 +1,22 @@
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
+config/scout.yml
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Jesse Newland
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
+= cucumber-scout
+
+TODO
+
+== Available Operators
+
+* be greater than
+* be less than
+* equal OR be
+* not equal OR not be
+
+== Running Cucumber Features
+
+Drop your license key into config/scout.yml, then run 'em like so:
+
+ cucumber features
+
+== Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add cucumber features for it. This is important so I don't break it in a
+ future version unintentionally.
+* Commit, do not mess with rakefile, version, or history.
+ (if you want to have your own version, that is fine but bump version in a
+ commit by itself I can ignore when I pull)
+* Send me a pull request. Bonus points for topic branches.
+
+== Copyright
+
+Copyright (c) 2010 Jesse Newland. See LICENSE for details.
@@ -0,0 +1,32 @@
+require 'rubygems'
+require 'rake'
+$LOAD_PATH.unshift 'lib'
+require 'cucumber/scout/version'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.version = Cucumber::Scout::VERSION
+ gem.name = "cucumber-scout"
+ gem.summary = %Q{Cucumber steps for verifing metrics from Scout's API}
+ gem.description = %Q{Cucumber steps for verifing metrics from Scout's API}
+ gem.email = "jnewland@gmail.com"
+ gem.homepage = "http://github.com/jnewland/cucumber-scout"
+ gem.authors = ["Jesse Newland"]
+ gem.add_dependency "scout_scout", "~> 0.0.4"
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = Cucumber::Scout::VERSION
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "cucumber-scout #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,5 @@
+account:
+email:
+password:
+hostname: # a server with the 'server overview' plugin installed
+plugin: Server Overview
@@ -0,0 +1,53 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{cucumber-scout}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jesse Newland"]
+ s.date = %q{2010-06-08}
+ s.description = %q{Cucumber steps for verifing metrics from Scout's API}
+ s.email = %q{jnewland@gmail.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "config/scout.yml.example",
+ "cucumber-scout.gemspec",
+ "features/cucumber.feature",
+ "features/steps/config_steps.rb",
+ "features/support/env.rb",
+ "lib/cucumber/scout.rb",
+ "lib/cucumber/scout/steps.rb",
+ "lib/cucumber/scout/version.rb"
+ ]
+ s.homepage = %q{http://github.com/jnewland/cucumber-scout}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.6}
+ s.summary = %q{Cucumber steps for verifing metrics from Scout's API}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<scout_scout>, ["~> 0.0.4"])
+ else
+ s.add_dependency(%q<scout_scout>, ["~> 0.0.4"])
+ end
+ else
+ s.add_dependency(%q<scout_scout>, ["~> 0.0.4"])
+ end
+end
+
@@ -0,0 +1,26 @@
+Feature: Setup
+ As a dev wanting to verify the Scout API
+ You should be able to initialize auth details in the background
+
+ Background:
+ Given we load our Scout account info from the config file
+
+ Scenario: Installing the gem
+ When a scenario runs
+ Then the Scout API is responsive
+
+ Scenario: Less than
+ Given I load the sample server's metrics
+ Then 'cpu_last_minute' should be less than 1
+
+ Scenario: Equal
+ Given I load the sample server's metrics
+ Then 'disk_size' should be 22
+
+ Scenario: Greater than
+ Given I load the sample server's metrics
+ Then 'cpu_last_minute' should be greater than 0.001
+
+ Scenario: Not equal
+ Given I load the sample server's metrics
+ Then 'cpu_last_minute' should not equal 100
@@ -0,0 +1,20 @@
+require 'yaml'
+Given 'we load our Scout account info from the config file' do
+ config = YAML.load_file(File.join(Dir.pwd, 'config', 'scout.yml'))
+ Given "our Scout account name is '"+config['account']+"'"
+ Given "our Scout email and password are '"+config['email']+"' and '"+config['password']+"'"
+ Given 'I load the sample server\'s metrics'
+end
+
+When /^a scenario runs$/ do
+ # noop
+end
+
+Given 'I load the sample server\'s metrics' do
+ config = YAML.load_file(File.join(Dir.pwd, 'config', 'scout.yml'))
+ Given "I get the metrics from the '"+config['plugin']+"' plugin on '"+config['hostname']+"'"
+end
+
+Then /^the Scout API is responsive$/ do
+ Then "'cpu_last_minute' should be less than 1"
+end
@@ -0,0 +1 @@
+require File.join(Dir.pwd, 'lib', 'cucumber', 'scout', 'steps.rb')
@@ -0,0 +1,30 @@
+require 'scout_scout'
+
+module Cucumber
+ module Scout
+
+ def self.scout_account=(name)
+ ScoutScout.account = name
+ end
+
+ def self.scout_auth(email, password)
+ ScoutScout.basic_auth email, password
+ end
+
+ class << self
+ attr_accessor :scout_hostname, :scout_plugin_name
+ end
+
+ protected
+
+ def self.value_for_hostname_plugin_and_descriptor(hostname=nil,plugin=nil,descriptor=nil)
+ hostname ||= self.scout_hostname
+ plugin ||= self.scout_plugin_name
+ ScoutScout::Server.first(hostname).plugins.find { |p| p.name.downcase == plugin.downcase }.descriptors.find { |d| d.name.downcase == descriptor.downcase }.value
+ end
+
+ end
+end
+
+World(Cucumber::Scout)
+require 'cucumber/nagios/steps'
@@ -0,0 +1,29 @@
+require 'cucumber/scout'
+
+Given /^(my|our) Scout account name is '([^\"]*)'$/ do |junk, name|
+ Cucumber::Scout.scout_account = name
+end
+
+Given /^(my|our) Scout email and password are '([^\"]*)' and '([^\"]*)'$/ do |junk, email, password|
+ Cucumber::Scout.scout_auth email, password
+end
+
+Given /^I get the metrics from the '([^\"]*)' plugin on '([^\"]*)'$/ do |plugin, hostname|
+ Cucumber::Scout.scout_hostname = hostname
+ Cucumber::Scout.scout_plugin_name = plugin
+end
+
+Then /^(the |)'([^\"]*)' should (be|be less than|be greater than|equal|not equal|not be) ([\d\.]+)( milliseconds| percent|)$/ do |predicate, metric, operator, intended_value, unit|
+ real_value = Cucumber::Scout.value_for_hostname_plugin_and_descriptor(Cucumber::Scout.scout_hostname, Cucumber::Scout.scout_plugin_name, metric).to_f
+ intended_value = intended_value.to_f
+ case operator
+ when 'be less than'
+ real_value.should < intended_value
+ when 'be greater than'
+ real_value.should > intended_value
+ when 'be', 'equal'
+ real_value.should == intended_value
+ when 'not be', 'not equal'
+ real_value.should_not == intended_value
+ end
+end
@@ -0,0 +1,5 @@
+module Cucumber
+ module Scout
+ VERSION = '0.0.1'
+ end
+end

0 comments on commit 9cb58dd

Please sign in to comment.