Sha256: fa6a359c38be3b29451cf834862c08c9cf9b1aa2b19aec2a0655207e559368e1

Contents?: true

Size: 1.8 KB

Versions: 12

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe LinuxAdmin::Partition do
  before(:each) do
    @disk = LinuxAdmin::Disk.new :path => '/dev/sda'
    @partition = LinuxAdmin::Partition.new :disk => @disk, :id => 2

    # stub out calls that modify system
    FileUtils.stub(:mkdir)
    @partition.stub(:run!)
  end

  describe "#path" do
    it "returns partition path" do
      @partition.path.should == '/dev/sda2'
    end
  end

  describe "#format_to" do
    it "uses mke2fs" do
      @partition.should_receive(:run!).
         with(@partition.cmd(:mke2fs),
              :params => { '-t' => 'ext4', nil => '/dev/sda2'})
      @partition.format_to('ext4')
    end

    it "sets fs type" do
      @partition.should_receive(:run!) # ignore actual formatting cmd
      @partition.format_to('ext4')
      @partition.fs_type.should == 'ext4'
    end
  end

  describe "#mount" do
    it "sets mount point" do
      @partition.should_receive(:run!) # ignore actual mount cmd
      @partition.mount
      @partition.mount_point.should == '/mnt/sda2'
    end

    context "mountpoint does not exist" do
      it "creates mountpoint" do
        File.should_receive(:directory?).with('/mnt/sda2').and_return(false)
        FileUtils.should_receive(:mkdir).with('/mnt/sda2')
        @partition.should_receive(:run!) # ignore actual mount cmd
        @partition.mount
      end
    end

    it "mounts partition" do
      @partition.should_receive(:run!).
         with(@partition.cmd(:mount),
              :params => { nil => ['/dev/sda2', '/mnt/sda2']})
      @partition.mount
    end
  end

  describe "#umount" do
    it "unmounts partition" do
      @partition.mount_point = '/mnt/sda2'
      @partition.should_receive(:run!).
         with(@partition.cmd(:umount),
              :params => { nil => ['/mnt/sda2']})
      @partition.umount
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
linux_admin-0.5.4 spec/partition_spec.rb
linux_admin-0.5.3 spec/partition_spec.rb
linux_admin-0.5.2 spec/partition_spec.rb
linux_admin-0.5.1 spec/partition_spec.rb
linux_admin-0.5.0 spec/partition_spec.rb
linux_admin-0.4.1 spec/partition_spec.rb
linux_admin-0.4.0 spec/partition_spec.rb
linux_admin-0.3.0 spec/partition_spec.rb
linux_admin-0.2.3 spec/partition_spec.rb
linux_admin-0.2.2 spec/partition_spec.rb
linux_admin-0.2.1 spec/partition_spec.rb
linux_admin-0.2.0 spec/partition_spec.rb