Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions lib/linux_admin/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ class LinuxAdmin
class CommandError < RuntimeError; end

module Common
def write(file, content)
raise ArgumentError, "file and content can not be empty" if file.blank? || content.blank?
File.open(file, "w") do |f|
f.write(content)
end
end

def cmd(cmd)
Distro.local.class::COMMANDS[cmd]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/linux_admin/fstab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def write!
@entries.each do |entry|
content += "#{entry.device} #{entry.mount_point} #{entry.fs_type} #{entry.mount_options} #{entry.dumpable} #{entry.fsck_order}\n"
end
write('/etc/fstab', content)
File.write('/etc/fstab', content)
self
end

Expand Down
6 changes: 0 additions & 6 deletions spec/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ class TestClass

subject { TestClass }

context ".write" do
it "no file no content" do
expect { subject.write("", "") }.to raise_error(ArgumentError)
end
end

context ".cmd" do
it "looks up local command from id" do
d = double(LinuxAdmin::Distro)
Expand Down
4 changes: 1 addition & 3 deletions spec/fstab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
entry.fsck_order = 1
LinuxAdmin::FSTab.instance.entries = [entry]

f = StringIO.new
File.should_receive(:open).with('/etc/fstab', 'w').and_yield(f)
File.should_receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1\n")
LinuxAdmin::FSTab.instance.write!
f.string.should == "/dev/sda1 / ext4 defaults 1 1\n"
end
end
end