Sha256: e853a7182ffaaf246de19a43c9bd213d2179d75f4755353a2a9b894926795e3e

Contents?: true

Size: 1.3 KB

Versions: 80

Compression:

Stored size: 1.3 KB

Contents

require "test_helper"

class ConfigBaseTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Config::Base
  end

  context "class methods" do
    should "enable configuration with proper accessor" do
      klass = Class.new(@klass)
      acc = :foo
      Vagrant::Config::Top.expects(:configures).with(acc, klass)
      klass.configures(acc)
    end
  end

  context "instance methods" do
    setup do
      @base = @klass.new
    end

    should "return a hash of instance variables" do
      data = { "foo" => "bar", "bar" => "baz" }

      data.each do |iv, value|
        @base.instance_variable_set("@#{iv}".to_sym, value)
      end

      result = @base.instance_variables_hash
      assert_equal data.length, result.length

      data.each do |iv, value|
        assert_equal value, result[iv]
      end
    end

    context "converting to JSON" do
      should "include magic `json_class`" do
        @iv_hash = { "foo" => "bar" }
        @base.expects(:instance_variables_hash).returns(@iv_hash)
        @json = { 'json_class' => @base.class.name }.merge(@iv_hash).to_json
        assert_equal @json, @base.to_json
      end

      should "not include top in the JSON hash" do
        @base.top = "FOO"
        hash = @base.instance_variables_hash
        assert !hash.has_key?(:top)
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 9 rubygems

Version Path
vagrantup-0.7.1 test/vagrant/config/base_test.rb
vagrantup-0.7.0 test/vagrant/config/base_test.rb
vagrant-fixed-ssh-1.0.7 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.7 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.6 test/unit_legacy/vagrant/config/base_test.rb
boxcar-0.10005.1 test/unit_legacy/vagrant/config/base_test.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/vagrant-1.0.5/test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.5 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.4 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.3 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.2 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.1 test/unit_legacy/vagrant/config/base_test.rb
vagrant-1.0.0 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.7 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.5 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.4 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.3 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.2 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.1 test/unit_legacy/vagrant/config/base_test.rb
vagrant-0.9.0 test/unit_legacy/vagrant/config/base_test.rb