spec/integration/spaces_spec.rb in noe-1.7.3 vs spec/integration/spaces_spec.rb in noe-1.7.4

- old
+ new

@@ -1,20 +1,20 @@ -require File.expand_path('../spec_helper', __FILE__) +require 'spec_helper' describe 'line endings and trailing spaces' do it 'all files should end with a single \n and have no trailing spaces' do begin - dir = File.expand_path('../../fixtures', __FILE__) - project_dir = dir + '/test' - Dir.chdir(dir) do + dir = Path.relative '../fixtures' + project_dir = dir / 'test' + dir.chdir do Noe::Main.run(%w{prepare --silent test}) end - Dir.chdir(project_dir) do - FileUtils.cp dir+'/test.noespec', project_dir + project_dir.chdir do + (dir/'test.noespec').cp(project_dir) Noe::Main.run(['go']) - Dir["**/*"].each { |file| - if File.file?(file) and File.size(file) > 0 - contents = File.read(file) + Path.glob("**/*") { |file| + if file.file? and !file.empty? + contents = file.read tail = contents[-3..-1] contents.each_line.with_index { |line, i| line.should match(/(?:^|\S)$/), "#{file} line #{i+1} has trailing spaces:\n#{line.inspect}" } @@ -22,9 +22,9 @@ "#{file} does not end with a single LF (#{tail.inspect})" end } end ensure - FileUtils.rm_r(project_dir) if File.exist? project_dir + project_dir.rm_r if project_dir.exist? end end end