Sha256: 34d6bdb9baead4d47c98ad81f7ec95e15b8832217d0fcc0eda96f2f065adc089

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path("../../../test_helper", __FILE__)

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

16 entries across 16 versions & 3 rubygems

Version Path
virtualbox-0.9.2 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.9.1 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.9.0 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.6 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.5 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.4 test/virtualbox/abstract_model/version_matcher_test.rb
velir_virtualbox-0.8.4 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.3 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.2 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.1 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.8.0 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.9 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.8 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.7 test/virtualbox/abstract_model/version_matcher_test.rb
virtualbox-0.7.6 test/virtualbox/abstract_model/version_matcher_test.rb
bbrowning-virtualbox-0.7.6.dev test/virtualbox/abstract_model/version_matcher_test.rb