Sha256: 39b9a0f30263322973500740c685748092446395125ce1b8756e6cc8c7aab8ab

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

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

class VersionMatcherTest < Test::Unit::TestCase
  setup do
    @module = VirtualBox::AbstractModel::VersionMatcher
    @klass = Class.new
    @klass.send(:extend, @module)
  end

  context "asserting version matches" do
    should "raise an exception if versions do not match" do
      assert_raises(VirtualBox::Exceptions::UnsupportedVersionException) {
        @klass.assert_version_match("3.1", "3.2.4")
      }
    end

    should "not raise an exception if versions do match" do
      assert_nothing_raised {
        @klass.assert_version_match("3.0", "3.0.14")
      }
    end
  end

  context "version matching" do
    should "return true if versions match" do
      assert @klass.version_match?("3.2", "3.2.4")
      assert !@klass.version_match?("3.1", "3.2.4")
    end
  end

  context "splitting version" do
    should "split into a max of two parts by period" do
      assert_equal %W[3 2], @klass.split_version("3.2.0")
      assert_equal %W[3 1], @klass.split_version("3.1.1.1.1")
    end

    should "return an empty array if it can't split" do
      assert_equal [], @klass.split_version(nil)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
virtualbox-0.7.5 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.4 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.3 test/virtualbox/abstract_model/version_matcher_test.rb