Sha256: 40d58eab0d808a59d3dbf6b36f0968f4c7b5b9db01bdfb5576dcc186dc93ce9f

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

class VersionTest < Test::Unit::TestCase
  module VersionTestMod
    extend VirtualBox::Version
  end

  setup do
    @lib = mock("lib")
    @vbox = mock("vbox")

    VirtualBox::Lib.stubs(:lib).returns(@lib)
    @lib.stubs(:virtualbox).returns(@vbox)

    @module = VersionTestMod
  end

  context "checking if supported version of VirtualBox" do
    should "return true if version is not nil" do
      @module.stubs(:version).returns(:foo)
      assert @module.supported?
    end

    should "return false if version is nil" do
      @module.stubs(:version).returns(nil)
      assert !@module.supported?
    end
  end

  should "return the version" do
    version = mock("version")
    @vbox.expects(:version).returns(version)
    assert_equal version, @module.version
  end

  should "return nil if an error occurs" do
    @vbox.expects(:version).raises(LoadError)
    assert @module.version.nil?
  end

  should "return the revision" do
    revision = mock("revision")
    @vbox.expects(:revision).returns(revision)
    assert_equal revision, @module.revision
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
virtualbox-0.7.2 test/virtualbox/version_test.rb
virtualbox-0.7.1 test/virtualbox/version_test.rb
virtualbox-0.7.0 test/virtualbox/version_test.rb