summaryrefslogtreecommitdiff
path: root/test/test_helper.rb
blob: a031caa53c29b22106c24ad667630d9d61d54475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'rubygems'
require File.expand_path('../../lib/leap_cli/load_paths', __FILE__)
require 'minitest/autorun'
require 'leap_cli'

class MiniTest::Unit::TestCase
  attr_accessor :ruby_path

  # Add global extensions to the test case class here

  def setup
    LeapCli::Path.set_platform_path(test_platform_path)
    LeapCli::Path.set_provider_path(test_provider_path)
  end

  def manager
    @manager ||= begin
      manager = LeapCli::Config::Manager.new
      manager.load
      manager
    end
  end

  def provider
    manager.provider
  end

  def base_path
    File.expand_path '../..', __FILE__
  end

  def leap_bin(*args)
    `#{ruby_path} #{base_path}/bin/leap #{args.join ' '}`
  end

  def test_platform_path
    "#{base_path}/test/leap_platform"
  end

  def test_provider_path
    "#{base_path}/test/provider"
  end

  def with_multiple_rubies(&block)
    ['ruby1.8', 'ruby1.9.1'].each do |ruby|
      self.ruby_path = `which #{ruby}`.strip
      next unless ruby_path.chars.any?
      yield
    end
    self.ruby_path = ""
  end

end