cpspec 0.0.1

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Version 0.0.1
2
+ * initial release
3
+ * has run_test extention to vagrant. Vanilla test unit tests.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "bundler", "1.1.rc.6"
4
+ gem "vagrant", "0.8.7"
5
+ gem "rake", "0.9.2.2"
6
+
7
+ group :development do
8
+ gem "jeweler", "~> 1.6.4"
9
+ end
10
+
11
+ group :test do
12
+ gem 'mocha'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-tar-minitar (0.5.2)
5
+ erubis (2.7.0)
6
+ ffi (1.0.11)
7
+ git (1.2.5)
8
+ i18n (0.6.0)
9
+ jeweler (1.6.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ json (1.5.2)
14
+ metaclass (0.0.1)
15
+ mocha (0.10.0)
16
+ metaclass (~> 0.0.1)
17
+ net-scp (1.0.4)
18
+ net-ssh (>= 1.99.1)
19
+ net-ssh (2.1.4)
20
+ rake (0.9.2.2)
21
+ thor (0.14.6)
22
+ vagrant (0.8.7)
23
+ archive-tar-minitar (= 0.5.2)
24
+ erubis (~> 2.7.0)
25
+ i18n (~> 0.6.0)
26
+ json (~> 1.5.1)
27
+ net-scp (~> 1.0.4)
28
+ net-ssh (~> 2.1.4)
29
+ thor (~> 0.14.6)
30
+ virtualbox (~> 0.9.1)
31
+ virtualbox (0.9.2)
32
+ ffi (~> 1.0.9)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (= 1.1.rc.6)
39
+ jeweler (~> 1.6.4)
40
+ mocha
41
+ rake (= 0.9.2.2)
42
+ vagrant (= 0.8.7)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Shishir Das
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,41 @@
1
+ = cpspec
2
+ Cpspec is a framework which allows behaviour driven development for chef cookbooks/Puppet Manifests. It enables testing of the cookbooks on the local box. The same test then can be executed on Target machine. It is a vagrant extension. Use vagrant to apply cookbook on the local environment and then run test to assert if desired changes are applied.
3
+
4
+
5
+
6
+ = Installation
7
+ * Install vagrant. Installation instructions can be found here.(http://vagrantup.com/docs/getting-started/index.html)
8
+
9
+ gem install cpsec
10
+
11
+ = Usage
12
+ * Write test for the cook books
13
+
14
+ require 'test/unit'
15
+ class TestJavaCookbook
16
+ def test_java_installed_in_correct_path
17
+ assert_true File.exists?("/usr/bin/java")
18
+ end
19
+ end
20
+
21
+ * Specify the test directory path (Absolute or relative)
22
+
23
+ Vagrant::Config.run do |config|
24
+ config.test.directory = "env-test"
25
+ config.vm.define :dev do |conf|
26
+ conf.vm.box = "lucid32"
27
+ conf.vm.provision :chef_solo do |chef|
28
+ chef.cookbooks_path = "chef-repo/cookbooks"
29
+ chef.add_recipe "java"
30
+ end
31
+ end
32
+ end
33
+
34
+ * Run tests
35
+ vagrant run_test
36
+
37
+ == Copyright
38
+
39
+ Copyright (c) 2011 Shishir Das. See LICENSE.txt for
40
+ further details.
41
+
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cpspec"
18
+ gem.homepage = "http://github.com/shishir/cpspec"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{testing framework for chef and puppet}
21
+ gem.description = %Q{lets to run your chef cookbooks or puppet manifest again local vm and runs test on it}
22
+ gem.email = "shishir.das@gmail.com"
23
+ gem.authors = ["Shishir Das"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/rdoctask'
29
+ Rake::RDocTask.new do |rdoc|
30
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
31
+
32
+ rdoc.rdoc_dir = 'rdoc'
33
+ rdoc.title = "cpspec #{version}"
34
+ rdoc.rdoc_files.include('README*')
35
+ rdoc.rdoc_files.include('lib/**/*.rb')
36
+ end
37
+
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.libs << "lib"
42
+ t.test_files = FileList['test/**/test*.rb']
43
+ t.verbose = true
44
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,9 @@
1
+ module Cpspec
2
+ class RunTest < Vagrant::Command::Base
3
+ register "run_test", "Runs a tests for cookbooks inside the VM environment"
4
+ def execute
5
+ target_vms.each {|vm| vm.env.actions.run(:test)}
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,10 @@
1
+ module Cpspec
2
+ class Config < Vagrant::Config::Base
3
+ configures :test
4
+ attr_accessor :directory
5
+
6
+ def validate(errors)
7
+ errors.add("You need a test directory") if !directory
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ module Cpspec
2
+ class Middleware
3
+ def initialize(app, env)
4
+ @app = app
5
+ @env = env
6
+ end
7
+
8
+ def call(env)
9
+ files = Dir.glob("test/*.rb")
10
+ if env["vm"].created? && env["vm"].vm.running?
11
+ files.each do |file|
12
+ command = "ruby /vagrant/#{file}".strip
13
+
14
+ env["vm"].ssh.execute do |ssh|
15
+ env.ui.info "Running Test: #{file}"
16
+
17
+ ssh.exec!("#{command}") do |channel, type, data|
18
+ $stdout.print(data) if type != :exit_status
19
+ end
20
+ $stdout.puts
21
+ end
22
+ end
23
+ end
24
+ @app.call(env)
25
+ end
26
+ end
27
+ end
data/lib/cpspec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'vagrant'
2
+ require File.expand_path(__FILE__) + "/../cpspec/command"
3
+ require File.expand_path(__FILE__) + "/../cpspec/middleware"
4
+ require File.expand_path(__FILE__) + "/../cpspec/config"
5
+
6
+ cpspec = Vagrant::Action::Builder.new do
7
+ use Cpspec::Middleware
8
+ end
9
+
10
+ Vagrant::Action.register(:test, cpspec)
11
+
@@ -0,0 +1 @@
1
+ require "#{File.expand_path(__FILE__)}/../cpspec"
@@ -0,0 +1,18 @@
1
+ require "#{File.expand_path(__FILE__)}/../../test_helper"
2
+
3
+ module Cpspec
4
+ class TestCommand < Test::Unit::TestCase
5
+ include Vagrant::TestHelpers
6
+
7
+ def setup
8
+ @env = vagrant_env
9
+ end
10
+
11
+ def test_command
12
+ @env.vms.values.each do |vm|
13
+ vm.env.actions.expects(:run).with(:test)
14
+ end
15
+ @env.cli("run_test")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ require "#{File.expand_path(__FILE__)}/../../test_helper"
2
+
3
+ module Cpspec
4
+ class ConfigTest < Test::Unit::TestCase
5
+ def setup
6
+ @config = Cpspec::Config.new
7
+ @errors = Vagrant::Config::ErrorRecorder.new
8
+ end
9
+
10
+ def test_directory_should_be_specified
11
+ @config.validate(@errors)
12
+ assert !@errors.errors.empty?
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'vagrant'
2
+ require 'cpspec/config'
3
+ require 'cpspec/command'
4
+ require 'test/unit'
5
+ require 'mocha'
6
+
7
+
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cpspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Shishir Das
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &70220521739620 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.rc.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70220521739620
25
+ - !ruby/object:Gem::Dependency
26
+ name: vagrant
27
+ requirement: &70220521738260 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70220521738260
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70220521736700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.2.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70220521736700
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &70220521734520 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70220521734520
58
+ description: lets to run your chef cookbooks or puppet manifest again local vm and
59
+ runs test on it
60
+ email: shishir.das@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - LICENSE.txt
65
+ - README.rdoc
66
+ files:
67
+ - .document
68
+ - CHANGELOG.md
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - LICENSE.txt
72
+ - README.rdoc
73
+ - Rakefile
74
+ - VERSION
75
+ - lib/cpspec.rb
76
+ - lib/cpspec/command.rb
77
+ - lib/cpspec/config.rb
78
+ - lib/cpspec/middleware.rb
79
+ - lib/vagrant_init.rb
80
+ - test/cpspec/test_command.rb
81
+ - test/cpspec/test_config.rb
82
+ - test/test_helper.rb
83
+ homepage: http://github.com/shishir/cpspec
84
+ licenses:
85
+ - MIT
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
97
+ - 0
98
+ hash: -1665583880306556545
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.10
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: testing framework for chef and puppet
111
+ test_files: []