Sha256: 529f143fa26c3ce0b53bad11829d403efc539afce2a3bba735f83c1236b2659a

Contents?: true

Size: 905 Bytes

Versions: 19

Compression:

Stored size: 905 Bytes

Contents

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

describe Vagrant::Hosts do
  let(:registry) { Hash.new }
  let(:base_class) { Vagrant::Plugin::V1::Host }

  it "detects the host that matches true" do
    foo_klass = Class.new(base_class) do
      def self.match?; false; end
    end

    bar_klass = Class.new(base_class) do
      def self.match?; true; end
    end

    registry[:foo] = foo_klass
    registry[:bar] = bar_klass

    described_class.detect(registry).should == bar_klass
  end

  it "detects the host that matches true with the highest precedence first" do
    foo_klass = Class.new(base_class) do
      def self.match?; true; end
    end

    bar_klass = Class.new(base_class) do
      def self.match?; true; end
      def self.precedence; 9; end
    end

    registry[:foo] = foo_klass
    registry[:bar] = bar_klass

    described_class.detect(registry).should == bar_klass
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/hosts_test.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/hosts_test.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/hosts_test.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/hosts_test.rb
tnargav-1.3.6 test/unit/vagrant/hosts_test.rb
tnargav-1.3.3 test/unit/vagrant/hosts_test.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/hosts_test.rb
tnargav-1.2.3 test/unit/vagrant/hosts_test.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/hosts_test.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/hosts_test.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/hosts_test.rb
tnargav-1.2.2 test/unit/vagrant/hosts_test.rb
vagrantup-1.1.3 test/unit/vagrant/hosts_test.rb
vagrantup-1.1.2 test/unit/vagrant/hosts_test.rb
vagrantup-1.1.1 test/unit/vagrant/hosts_test.rb
vagrantup-1.1.0 test/unit/vagrant/hosts_test.rb
vagrantup-1.1.4 test/unit/vagrant/hosts_test.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/test/unit/vagrant/hosts_test.rb
vagrant-lxc-0.0.1 vendor/vagrant/test/unit/vagrant/hosts_test.rb