spec/fstab_spec.rb in linux_admin-0.9.1 vs spec/fstab_spec.rb in linux_admin-0.9.2

- old
+ new

@@ -1,6 +1,5 @@ -require 'spec_helper' require 'stringio' describe LinuxAdmin::FSTab do before do # Reset the singleton so subsequent tests get a new instance @@ -11,13 +10,13 @@ fstab = <<eos eos - File.should_receive(:read).with('/etc/fstab').and_return(fstab) - LinuxAdmin::FSTab.instance.entries.size.should == 3 - LinuxAdmin::FSTab.instance.entries.any? { |e| e.has_content? }.should be_false + expect(File).to receive(:read).with('/etc/fstab').and_return(fstab) + expect(LinuxAdmin::FSTab.instance.entries.size).to eq(3) + expect(LinuxAdmin::FSTab.instance.entries.any? { |e| e.has_content? }).to be_falsey end it "creates FSTabEntry for each line in fstab" do fstab = <<eos # Comment, indented comment, comment with device information @@ -25,31 +24,31 @@ # /dev/sda1 / ext4 defaults 1 1 /dev/sda1 / ext4 defaults 1 1 /dev/sda2 swap swap defaults 0 0 eos - File.should_receive(:read).with('/etc/fstab').and_return(fstab) + expect(File).to receive(:read).with('/etc/fstab').and_return(fstab) entries = LinuxAdmin::FSTab.instance.entries - entries.size.should == 6 + expect(entries.size).to eq(6) - entries[0].comment.should == "# Comment, indented comment, comment with device information\n" - entries[1].comment.should == "# /dev/sda1 / ext4 defaults 1 1\n" - entries[2].comment.should == "# /dev/sda1 / ext4 defaults 1 1\n" - entries[3].comment.should == nil - entries[4].device.should == '/dev/sda1' - entries[4].mount_point.should == '/' - entries[4].fs_type.should == 'ext4' - entries[4].mount_options.should == 'defaults' - entries[4].dumpable.should == 1 - entries[4].fsck_order.should == 1 + expect(entries[0].comment).to eq("# Comment, indented comment, comment with device information\n") + expect(entries[1].comment).to eq("# /dev/sda1 / ext4 defaults 1 1\n") + expect(entries[2].comment).to eq("# /dev/sda1 / ext4 defaults 1 1\n") + expect(entries[3].comment).to eq(nil) + expect(entries[4].device).to eq('/dev/sda1') + expect(entries[4].mount_point).to eq('/') + expect(entries[4].fs_type).to eq('ext4') + expect(entries[4].mount_options).to eq('defaults') + expect(entries[4].dumpable).to eq(1) + expect(entries[4].fsck_order).to eq(1) - entries[5].device.should == '/dev/sda2' - entries[5].mount_point.should == 'swap' - entries[5].fs_type.should == 'swap' - entries[5].mount_options.should == 'defaults' - entries[5].dumpable.should == 0 - entries[5].fsck_order.should == 0 + expect(entries[5].device).to eq('/dev/sda2') + expect(entries[5].mount_point).to eq('swap') + expect(entries[5].fs_type).to eq('swap') + expect(entries[5].mount_options).to eq('defaults') + expect(entries[5].dumpable).to eq(0) + expect(entries[5].fsck_order).to eq(0) end describe "#write!" do it "writes entries to /etc/fstab" do # maually set fstab @@ -59,14 +58,14 @@ entry.fs_type = 'ext4' entry.mount_options = 'defaults' entry.dumpable = 1 entry.fsck_order = 1 entry.comment = "# more" - LinuxAdmin::FSTab.any_instance.stub(:refresh) # don't read /etc/fstab + allow_any_instance_of(LinuxAdmin::FSTab).to receive(:refresh) # don't read /etc/fstab LinuxAdmin::FSTab.instance.maximum_column_lengths = [9, 1, 4, 8, 1, 1, 1] LinuxAdmin::FSTab.instance.entries = [entry] - File.should_receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1 # more\n") + expect(File).to receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1 # more\n") LinuxAdmin::FSTab.instance.write! end end end