Sha256: 96989eabdcb707dcb64b9f5a966dd1397c618f5142ec6498992a5e07ef2a5c01

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'

require 'minitest/autorun'
require 'resolver'
require 'fileutils'


class Module
  def redefine_const(name, value)
    __send__(:remove_const, name) if const_defined?(name)
    const_set(name, value)
  end
end

VANILA =<<H
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
H

DIRTY =<<H
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 127.0.1.1
H

FAKED = '/tmp/resolv.conf'

class TestResolver < MiniTest::Unit::TestCase

  def setup
    Object.redefine_const(:RESOLV,FAKED)
    File.open(FAKED, 'w') {|f| f.write(VANILA) }
    @resolver = VagrantDns::ResolvConf.new
  end

  def teardown 
    FileUtils.rm FAKED
  end

  def test_appeding
    @resolver.append()
    assert_equal File.open(FAKED,'r').read, DIRTY
  end

  def test_clearing
    @resolver.append()
    @resolver.clear()
    assert_equal File.open(FAKED,'r').read, VANILA
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-dns-server-0.4.3 test/resolver_test.rb
vagrant-dns-server-0.4.2 test/resolver_test.rb
vagrant-dns-server-0.4.1 test/resolver_test.rb
vagrant-dns-server-0.4 test/resolver_test.rb
vagrant-dns-server-0.3 test/resolver_test.rb
vagrant-dns-server-0.2 test/resolver_test.rb