require_relative '../spec_helper'

describe 'bind::default' do
  let(:chef_run) do
    ChefSpec::Runner.new do |node|
      node.set["bind"] = {
        zones: {
          "lctp" => {
            records: [{ name: "node1", type: "A", value: "172.28.128.101" }]
          },
          "128.28.172.in-addr.arpa" => {
            records: [{ name: "101", type: "PTR", value: "node1" }]
          }
        },
        trusted_subnets: ["localhost", "localnets", "172.28.128.101"]
      }
    end.converge(described_recipe)
  end

  it "should setup named" do
    chef_run.should render_file("/etc/bind/named.conf").with_content("lctp")
    chef_run.should render_file("/etc/bind/named.conf.options").with_content("8.8.8.8")
    chef_run.should render_file("/etc/bind/lctp").with_content("node1")
    chef_run.should render_file("/etc/bind/128.28.172.in-addr.arpa").with_content("node1")
    chef_run.should install_package("bind9")
  end
end
