This is what I have:
it "should be able to get a valid directory path" do
@asset.some_file_path.should == "/something/test.jpg"
end
The problem is that some_file_path returns "/not_here_yet.jpg" if there is no existing file.
def some_file_path
if File.exists(self.my_image_path)
return my_image_path
else
return "/not_here_yet.jpg
end
end
I don't really want to create a new file in my tests. Is there a way for me to fake the existence of the file?
I'm thinking something in the lines of :
it "should be able to get a valid directory path" do
AwesomeFakeFileCreator.create(@asset.my_image_path)
@asset.some_file_path.should == "/something/test.jpg"
end
Is this possible? How can I do such a thing?
Edit: I looked a bit at FakeFS but I'm not sure it answers my question
You could do something on the lines of
it "should be able to get a valid directory path" do
File.stub!(:exists?).and_return(true)
@asset.stub!(:my_image_path).and_return("/something/test.jpg")
@asset.some_file_path.should == "/something/test.jpg"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With