Skip to content

Commit

Permalink
Avoid result sorting by using =~ for array matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed May 13, 2011
1 parent 4e47e3e commit 1db2456
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions spec/guard/listener_spec.rb
Expand Up @@ -56,24 +56,24 @@
context "without the :all option" do
it "finds modified files only in the directory supplied" do
FileUtils.touch([file1, file2, file3])
subject.modified_files([@fixture_path.join("folder1/")], {}).sort.should eql ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
subject.modified_files([@fixture_path.join("folder1/")], {}).should =~ ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
end
end

context "with the :all options" do
it "finds modified files within subdirectories" do
FileUtils.touch([file1, file2, file3])
subject.modified_files([@fixture_path.join("folder1/")], { :all => true }).sort.should eql ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt", "spec/fixtures/folder1/folder2/file2.txt"]
subject.modified_files([@fixture_path.join("folder1/")], { :all => true }).should =~ ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt", "spec/fixtures/folder1/folder2/file2.txt"]
end
end

context "without updating the content" do
it "ignores the files for the second time" do
FileUtils.touch([file1, file2, file3])
subject.modified_files([@fixture_path.join("folder1/")], {}).sort.should eql ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
subject.modified_files([@fixture_path.join("folder1/")], {}).should =~ ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
sleep 0.6
FileUtils.touch([file1, file2, file3])
subject.modified_files([@fixture_path.join("folder1/")], {}).should eql []
subject.modified_files([@fixture_path.join("folder1/")], {}).should == []
end
end

Expand All @@ -82,11 +82,11 @@

it "identifies the files for the second time" do
FileUtils.touch([file1, file2, file3])
subject.modified_files([@fixture_path.join("folder1/")], {}).sort.should eql ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
subject.modified_files([@fixture_path.join("folder1/")], {}).should =~ ["spec/fixtures/folder1/deletedfile1.txt", "spec/fixtures/folder1/file1.txt"]
sleep 0.6
FileUtils.touch([file2, file3])
File.open(file1, "w") { |f| f.write("changed content") }
subject.modified_files([@fixture_path.join("folder1/")], {}).sort.should eql ["spec/fixtures/folder1/file1.txt"]
subject.modified_files([@fixture_path.join("folder1/")], {}).should =~ ["spec/fixtures/folder1/file1.txt"]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/listeners/polling_spec.rb
Expand Up @@ -40,7 +40,7 @@
FileUtils.touch file1
FileUtils.touch file2
stop
@results.sort.should == ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
@results.should =~ ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
end
end

Expand Down

0 comments on commit 1db2456

Please sign in to comment.