Sha256: 8ef08ba35d317835d32283e9896186866bb2b81c4cb5bda539a7d1f3b23f1993

Contents?: true

Size: 1.74 KB

Versions: 15

Compression:

Stored size: 1.74 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")

describe AutomateIt::AddressManager do
  before(:all) do
    @a = AutomateIt.new(:verbosity => Logger::WARN)
    @m = @a.address_manager
    @d = @a.address_manager.driver_for(:hostnames_for)
  end

  it "should be able to convert netmasks to CIDR addresses" do
    @d.send(:mask_to_cidr, "255.255.255.0").should == 24
  end

  it "should be able to convert CIDR addresses to netmasks" do
    @d.send(:cidr_to_mask, 24).should == "255.255.255.0"
  end

  it "should be able to convert decimals to binaries" do
    @d.send(:dec2bin, 255).should == "11111111"
  end

  it "should be able to convert binaries to decimals" do
    @d.send(:bin2dec, "11111111").should == 255
  end

  it "should be able to derive interface and label from a device" do
    @d.send(:_interface_and_label, :device => "eth0").should == "eth0"
  end

  it "should be able to derive interface and label from a device and alias" do
    @d.send(:_interface_and_label, :device => "eth0", :label => "1").should == "eth0:1"
  end

  it "should fail to derive interface and lable from inadequate options" do
    lambda { @d.send(:_interface_and_label, :label => "1") }.should raise_error(ArgumentError)
  end

  it "should be able to prepend arguments to ifconfig commands" do
    @d.send(:_ifconfig_helper, :del, 
      {:address => "127.0.0.1", :device => "eth0", :label => "1"}, 
      {:prepend => "inet"}).should == "ifconfig eth0:1 inet 127.0.0.1 down"
  end

  it "should be able to append arguments to ifconfig commands" do
    @d.send(:_ifconfig_helper, :del, 
      {:address => "127.0.0.1", :device => "eth0", :label => "1"}, 
      {:append => "unplumb"}).should == "ifconfig eth0:1 127.0.0.1 down unplumb"
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
automate-it-0.9.2 spec/unit/address_manager_spec.rb
automate-it-0.9.1 spec/unit/address_manager_spec.rb
automate-it-0.9.0 spec/unit/address_manager_spec.rb
automateit-0.71103 spec/unit/address_manager_spec.rb
automateit-0.71220 spec/unit/address_manager_spec.rb
automateit-0.71112 spec/unit/address_manager_spec.rb
automateit-0.71221 spec/unit/address_manager_spec.rb
automateit-0.71219 spec/unit/address_manager_spec.rb
automateit-0.71111 spec/unit/address_manager_spec.rb
automateit-0.71104 spec/unit/address_manager_spec.rb
automateit-0.71226.1 spec/unit/address_manager_spec.rb
automateit-0.80624 spec/unit/address_manager_spec.rb
automateit-0.71230 spec/unit/address_manager_spec.rb
automateit-0.80116 spec/unit/address_manager_spec.rb
automateit-0.71226 spec/unit/address_manager_spec.rb