Sha256: 7a45702e7a27ff9d21dc36b5f8b1811e8909f3f2d5ce4007e4b0429edb8c852d

Contents?: true

Size: 1.74 KB

Versions: 18

Compression:

Stored size: 1.74 KB

Contents

require 'rubygems'
require 'bundler'
require 'spork'

Spork.prefork do
  require 'rspec'
  require 'pp'
  require 'aruba/cucumber'

  APP_ROOT = File.expand_path('../../../', __FILE__)

  ENV['RUBY_ENV'] = 'test'
  ENV['BERKSHELF_PATH'] = File.join(APP_ROOT, 'tmp', 'berkshelf')
  ENV['BERKSHELF_CHEF_CONFIG'] = File.join(APP_ROOT, 'spec', 'config', 'knife.rb')

  # Workaround for RSA Fingerprint prompt in Travis CI
  git_ssh_path = '/tmp/git_ssh.sh'
  unless File.exist? git_ssh_path
    git_ssh = File.new(git_ssh_path, 'w+')
    git_ssh.puts 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 $2'
    git_ssh.chmod 0775
    git_ssh.flush
    git_ssh.close
  end

  ENV['GIT_SSH'] = git_ssh_path

  Dir[File.join(APP_ROOT, 'spec/support/**/*.rb')].each {|f| require f}

  World(Berkshelf::TestGenerators)

  Before do
    set_env 'RUBY_ENV', 'test'
    clean_cookbook_store
    generate_berks_config(File.join(ENV['BERKSHELF_PATH'], 'config.json'))
    @aruba_io_wait_seconds = 5
    @aruba_timeout_seconds = 30
  end

  Before('@slow_process') do
    @aruba_timeout_seconds = 60
    @aruba_io_wait_seconds = 30
  end

  # Chef Zero
  require 'chef_zero/server'
  @server = ChefZero::Server.new(port: 4000, generate_real_keys: false)
  @server.start_background

  at_exit do
    @server.stop if @server && @server.running?
  end

  def cookbook_store
    Pathname.new(File.join(ENV['BERKSHELF_PATH'], 'cookbooks'))
  end

  def clean_cookbook_store
    FileUtils.rm_rf(cookbook_store)
    FileUtils.mkdir_p(cookbook_store)
  end

  def app_root_path
    Pathname.new(APP_ROOT)
  end

  def tmp_path
    app_root_path.join('spec/tmp')
  end

  def fixtures_path
    app_root_path.join('spec/fixtures')
  end
end

Spork.each_run do
  require 'berkshelf'
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
berkshelf-2.0.18 features/support/env.rb
berkshelf-2.0.17 features/support/env.rb
berkshelf-2.0.16 features/support/env.rb
berkshelf-2.0.15 features/support/env.rb
berkshelf-2.0.14 features/support/env.rb
berkshelf-2.0.13 features/support/env.rb
berkshelf-2.0.12 features/support/env.rb
berkshelf-2.0.11 features/support/env.rb
berkshelf-2.0.10 features/support/env.rb
berkshelf-2.0.9 features/support/env.rb
berkshelf-2.0.8 features/support/env.rb
berkshelf-2.0.7 features/support/env.rb
berkshelf-2.0.6 features/support/env.rb
berkshelf-2.0.5 features/support/env.rb
berkshelf-2.0.4 features/support/env.rb
berkshelf-2.0.3 features/support/env.rb
berkshelf-2.0.1 features/support/env.rb
berkshelf-2.0.0 features/support/env.rb