diff --git a/lib/linux_admin/fstab.rb b/lib/linux_admin/fstab.rb index 41bb36d..647fe30 100644 --- a/lib/linux_admin/fstab.rb +++ b/lib/linux_admin/fstab.rb @@ -56,13 +56,7 @@ def write! private def read - contents = File.read('/etc/fstab') - contents = contents.lines.to_a - contents.reject! { |line| - first_char = line.strip[0] - first_char == '#' || first_char =~ /\s/ - } - contents + File.read('/etc/fstab').lines.find_all {|line| !line.blank? && !line.strip.starts_with?("#")} end def refresh diff --git a/spec/fstab_spec.rb b/spec/fstab_spec.rb index 4199b8f..d6c8111 100644 --- a/spec/fstab_spec.rb +++ b/spec/fstab_spec.rb @@ -2,8 +2,26 @@ require 'stringio' describe LinuxAdmin::FSTab do + before do + # Reset the singleton so subsequent tests get a new instance + Singleton.send :__init__, LinuxAdmin::FSTab + end + + it "newline, single spaces, tab" do + fstab = <