Sha256: 41678d1680244d36c0a0710f9f6476f2d1b26a88d657b834a2d362ef92395f8d

Contents?: true

Size: 1.93 KB

Versions: 7

Compression:

Stored size: 1.93 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
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/rvm'
require 'cuken/api/chef'
require 'cuken/api/chef/knife'

# 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
    # or if that doesn't work due to a version incompatibility
    # config.mock_with RR::Adapters::Rspec
end

def test_rvmrc(rubie, gemset_name)
%Q{
ruby_id="#{rubie}"
gemset_id="#{gemset_name}"
environment_id=${ruby_id}@${gemset_id}
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
  && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
  \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
else
  # If the environment file has not yet been created, use the RVM CLI to select.
  rvm --create  "$environment_id"
fi
filename=${gemset_id}.gems
if [[ -s "$filename" ]] ; then
  rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
fi
}
end

def test_gems
%Q{
# cuken.gems generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator
1 -v1.0.0
2 -v3.0.5
3 -v0.6.7
}
end

def setup_rvmrc_gems_files(count)
  root= FileUtils.mkpath("/path/to/dir", :mode => 0755)
  full="/path/to/dir/#{(1..count).to_a.join('/')}"
  FileUtils.mkpath(full, :mode => 0755)
  Pathname(full).ascend do |d|
    num = File.basename d
    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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cuken-0.1.13 spec/spec_helper.rb
cuken-0.1.12 spec/spec_helper.rb
cuken-0.1.11 spec/spec_helper.rb
cuken-0.1.10 spec/spec_helper.rb
cuken-0.1.9 spec/spec_helper.rb
cuken-0.1.8 spec/spec_helper.rb
cuken-0.1.7 spec/spec_helper.rb