Sha256: d09b4b6780907bc592b013b72227e479e5ab7dfff79661891a2f39e98f579a85

Contents?: true

Size: 971 Bytes

Versions: 6

Compression:

Stored size: 971 Bytes

Contents

require "minitest/autorun"
require "minitest/unit"
require_relative "../lib/clusterfuck"

class TestSubnet < Minitest::Unit::TestCase
  include Clusterfuck

  def setup
    SubnetFactory.reset
    @subnet = SubnetFactory.next_subnet
  end

  def test_next_subnet
    assert_equal IPAddr.new("10.0.40.2"), @subnet.next_ip
  end

  def test_next_ip_on_subnet
    assert_equal IPAddr.new("10.0.40.2"), @subnet.next_ip
    assert_equal IPAddr.new("10.0.40.3"), @subnet.next_ip
  end

  def test_next_subnet_twice
    assert_equal IPAddr.new("10.0.40.2"), @subnet.next_ip

    subnet = SubnetFactory.next_subnet
    assert_equal IPAddr.new("10.0.41.2"), subnet.next_ip
  end

  def test_mask_returns_classic_syntax_netmask
    assert_equal "255.255.255.0", @subnet.next_ip.netmask
  end

  def test_cidr_on_subet
    assert_equal 24, IPAddr.new("10.0.0.0/24").cidr
  end

  def test_to_cidr_on_subet
    assert_equal "10.0.0.0/24", IPAddr.new("10.0.0.0/24").to_cidr
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-clusterfuck-0.0.7 test/subnet_test.rb
vagrant-clusterfuck-0.0.6 test/subnet_test.rb
vagrant-clusterfuck-0.0.5 test/subnet_test.rb
vagrant-clusterfuck-0.0.4 test/subnet_test.rb
vagrant-clusterfuck-0.0.3 test/subnet_test.rb
vagrant-clusterfuck-0.0.2 test/subnet_test.rb