spec/lib/sweeper_spec.rb in stowaway-0.2.0 vs spec/lib/sweeper_spec.rb in stowaway-0.2.2
- old
+ new
@@ -1,9 +1,10 @@
require "spec/spec_helper"
require "lib/stowaway/file"
require "lib/stowaway/sweeper"
require "lib/stowaway/matcher"
+require "spec/lib/io_mock.rb"
describe Stowaway::Sweeper do
Stowaway::Output.class_eval do
def print str;end
@@ -32,11 +33,11 @@
files = [Stowaway::FileObj.new("/fake/path1/button.jpg")]
sweeper.sweep("spec/data", files)
files.length.should == 1
end
- it "should output a message when sweeping through a file" do
+ it "should print the path to the file (relative to root) being swept through" do
@ignore << /testfile2/
sweeper.should_receive(:clr_print).once.with(" => /testfile1.txt")
sweeper.sweep("spec/data", [])
end
@@ -62,7 +63,14 @@
files = [Stowaway::FileObj.new("/a/stowaway.txt")]
sweeper.sweep("spec/data", files)
files.should_not be_empty
files.first.fullpath.should == "/a/stowaway.txt"
end
-
+
+ it "should ignore lines with invalid encoding" do
+ files = [Stowaway::FileObj.new("/fake/path1/button.jpg")]
+ File.stub!(:open).and_yield(IOMock.new)
+ sweeper.should_not_receive(:remove_match)
+ sweeper.sweep("spec/data", files)
+ end
+
end