spec/spec_helper.rb in cuken-0.1.13 vs spec/spec_helper.rb in cuken-0.1.15
- old
+ new
@@ -1,29 +1,45 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
+require 'bundler'
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
require 'rspec'
+#require 'cucumber'
require 'stringio'
require 'fakefs/safe'
require 'fakefs/spec_helpers'
require 'rvm'
require 'rr'
require 'chef/mixins'
require 'chef/knife/configure'
require 'chef/knife/client_create'
+require 'cuken/api/aruba'
require 'cuken/api/rvm'
require 'cuken/api/chef'
require 'cuken/api/chef/knife'
+require 'cuken/api/vagrant'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rr
include ::Cuken::Api::Chef
+ include ::Cuken::Api::Rvm
+ include ::Cuken::Api::Rvm::Gemsets
+ include ::Cuken::Api::Vagrant
+ include ::Vagrant::TestHelpers
+
# or if that doesn't work due to a version incompatibility
# config.mock_with RR::Adapters::Rspec
end
def test_rvmrc(rubie, gemset_name)
@@ -63,6 +79,29 @@
File.open("#{d.to_s}/.rvmrc", "w") { |f| f << test_rvmrc("ruby-1.9.2-p136", num) }
File.open("#{d.to_s}/#{num}.gems", "w") { |f| f << test_gems }
end
root.to_s
end
+def test_vagrantfile(names=['web','db'])
+%Q{
+Vagrant::Config.run do |config|
+ config.vm.define :#{names[0]} do |config|
+ config.vm.box = "#{names[0]}"
+ config.vm.forward_port("http", 80, 8080)
+ end
+ config.vm.define :#{names[1]} do |cnfg|
+ cnfg.vm.box = "#{names[1]}"
+ cnfg.vm.forward_port("#{names[1]}", 3306, 3306)
+ end
+end
+}
+end
+
+class ::VagrantVMExampleHelpers
+ include ::Cuken::Api::Aruba::Api
+ include ::Cuken::Api::Vagrant::VM
+
+ def self.create_vm_instance(name)
+ new(name)
+ end
+end