Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding specs

  • Loading branch information...
commit de78918e7d88fcf067cdaa041eedb4b464d13b3d 1 parent 4a46ebb
Philip (flip) Kromer authored
View
5 .watchr
@@ -7,7 +7,7 @@ def run_spec(file)
end
puts "Running #{file}"
- system "bundle exec rspec #{file}"
+ system "rspec #{file}"
puts
end
@@ -16,5 +16,6 @@ watch("spec/.*/*_spec\.rb") do |match|
end
watch("lib/(.*)\.rb") do |match|
- run_spec %{spec/#{match[1]}_spec.rb}
+ file = %{spec/#{match[1]}_spec.rb}
+ run_spec file if File.exists?(file)
end
View
1  Gemfile
@@ -5,6 +5,7 @@ gem 'json', "~> 1.5.1"
gem 'right_aws', "~> 2.1.0"
gem 'formatador', "~> 0.1.4"
gem 'choice', "~> 0.1.4"
+gem 'gorillib', "~> 0.1.3"
gem 'configliere', "~> 0.4.5"
gem 'highline', "~> 1.6.2"
gem 'fog', "~> 0.8.2"
View
6 Gemfile.lock
@@ -34,8 +34,9 @@ GEM
net-ssh (>= 2.1.3)
nokogiri (>= 1.4.4)
ruby-hmac
- formatador (0.1.3)
+ formatador (0.1.4)
git (1.2.5)
+ gorillib (0.1.3)
highline (1.6.2)
jeweler (1.5.2)
bundler (~> 1.0.0)
@@ -98,7 +99,8 @@ DEPENDENCIES
choice (~> 0.1.4)
configliere (~> 0.4.5)
fog (~> 0.8.2)
- formatador (~> 0.1.3)
+ formatador (~> 0.1.4)
+ gorillib (~> 0.1.3)
highline (~> 1.6.2)
jeweler (~> 1.5.2)
json (~> 1.5.1)
View
67 spec/cluster_chef_spec.rb
@@ -1,7 +1,70 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+require 'extlib/mash'
+module Chef
+ Chef::Config = Mash.new( :knife => Mash.new )
+end
+
+require CLUSTER_CHEF_DIR("lib/cluster_chef")
+
describe "cluster_chef" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
+ def load_example(name)
+ require(CLUSTER_CHEF_DIR('clusters', "#{name}.rb"))
+ end
+
+ def get_cluster name
+ load_example(name)
+ ClusterChef.cluster(name)
+ end
+
+ describe 'successfuly runs examples' do
+
+ describe 'demohadoop cluster' do
+ before :all do
+ @cluster = get_cluster(:demohadoop)
+ end
+
+ it 'loads successfuly' do
+ @cluster.should be_a(ClusterChef::Cluster)
+ @cluster.name.should == :demohadoop
+ end
+
+ it 'cluster is right' do
+ @cluster.to_hash.should == {
+ :name => :demohadoop,
+ :run_list => ["role[base_role]", "role[chef_client]", "role[ssh]", "role[big_package]"],
+ :chef_attributes => { :cluster_size =>2 },
+ :cluster_role => "demohadoop_cluster",
+ }
+ end
+
+ it 'facets are right' do
+ @cluster.facets.length.should == 2
+ @cluster.facet(:master).to_hash.should == {
+ :name => :master,
+ :run_list => ["role[nfs_server]", "role[hadoop]", "role[hadoop_s3_keys]", "role[hadoop_master]", "hadoop_cluster::bootstrap_format_namenode", "role[hadoop_initial_bootstrap]"],
+ :chef_attributes => {},
+ :facet_role => "demohadoop_master",
+ :instances => 1,
+ }
+ @cluster.facet(:worker).to_hash.should == {
+ :name => :worker,
+ :run_list => ["role[nfs_client]", "role[hadoop]", "role[hadoop_s3_keys]", "role[hadoop_worker]" ],
+ :chef_attributes => {},
+ :facet_role => "demohadoop_worker",
+ :instances => 2,
+ }
+ end
+
+ it 'security groups are right' do
+ gg = @cluster.facet(:worker).security_groups
+ gg.length.should == 1
+ gg[:nfs_client].to_hash.should == {
+ :name => :nfs_client,
+ :description => "cluster_chef generated group nfs_client"
+ }
+ end
+ end
end
end
+
View
19 spec/spec_helper.rb
@@ -1,28 +1,17 @@
require 'spork'
require 'rspec'
+CLUSTER_CHEF_DIR = File.expand_path(File.dirname(__FILE__)+'/..') unless defined?(CLUSTER_CHEF_DIR)
+def CLUSTER_CHEF_DIR(*paths) File.join(CLUSTER_CHEF_DIR, *paths); end
+
Spork.prefork do
# This code is run only once when the spork server is started
- ENV["RACK_ENV"] ||= 'test'
- RACK_ENV = ENV["RACK_ENV"] unless defined?(RACK_ENV)
-
- require File.join(File.dirname(__FILE__), '../lib/boot')
- $LOAD_PATH.unshift(File.dirname(__FILE__))
-
- require 'goliath'
- require 'em-synchrony'
- require 'goliath/test_helper'
- require 'support/test_helper'
-
# Requires custom matchers & macros, etc from files in ./support/ & subdirs
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+ Dir[CLUSTER_CHEF_DIR("spec/support/**/*.rb")].each {|f| require f}
# Configure rspec
RSpec.configure do |config|
- config.include Goliath::TestHelper, :example_group => {
- :file_path => /spec/
- }
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.