Class: Busser::RunnerPlugin::Rspec

Inherits:
Base
  • Object
show all
Defined in:
lib/busser/runner_plugin/rspec.rb

Overview

A Busser runner plugin for Rspec.

Author:

Instance Method Summary collapse

Instance Method Details

#testObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/busser/runner_plugin/rspec.rb', line 32

def test
  rspec_path = suite_path('rspec').to_s

  chef_apply do
    setup_file = File.join(rspec_path, "setup-recipe.rb")

    if File.exists?(setup_file)
      eval(IO.read(setup_file))
    end

    execute "bundle install --local || bundle install" do
      environment("PATH" => "#{ENV['PATH']}:#{Gem.bindir}")
      cwd rspec_path
      only_if { File.exists?(File.join(rspec_path, "Gemfile")) }
    end
  end

  Dir.chdir(rspec_path) do
    runner = File.expand_path(File.join(File.dirname(__FILE__), "..", "rspec", "runner.rb"))
    run_ruby_script!("#{runner} -I #{rspec_path} -I #{rspec_path}/lib #{rspec_path}")
  end
end