Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions spec/fstab_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require 'stringio'

describe LinuxAdmin::FSTab do
before do
# Reset the singleton so subsequent tests get a new instance
Singleton.send :__init__, LinuxAdmin::FSTab
end
subject { described_class.dup }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carbonin I think this before should be changed to subject { described_class.dup }. Than you can just change LinuxAdmin::FSTab to subject and the warnings should be gone.


it "has newline, single spaces, tab" do
fstab = <<eos
Expand All @@ -13,8 +10,8 @@

eos
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
expect(subject.instance.entries.size).to eq(3)
expect(subject.instance.entries.any?(&:has_content?)).to be_falsey
end

it "creates FSTabEntry for each line in fstab" do
Expand All @@ -27,7 +24,7 @@
/dev/sda2 swap swap defaults 0 0
eos
expect(File).to receive(:read).with('/etc/fstab').and_return(fstab)
entries = LinuxAdmin::FSTab.instance.entries
entries = subject.instance.entries
expect(entries.size).to eq(6)

expect(entries[0].comment).to eq("# Comment, indented comment, comment with device information\n")
Expand Down Expand Up @@ -60,12 +57,12 @@
entry.dumpable = 1
entry.fsck_order = 1
entry.comment = "# more"
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]
allow_any_instance_of(subject).to receive(:refresh) # in case this is the first time we reference .instance
subject.instance.maximum_column_lengths = [9, 1, 4, 8, 1, 1, 1]
subject.instance.entries = [entry]

expect(File).to receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1 # more\n")
LinuxAdmin::FSTab.instance.write!
subject.instance.write!
end
end
end