If I have a class like this
class Foo < File
# fun stuff
end
and I wanted to test that it is indeed inherits from File, I could write
describe Foo
let(:a_file) { Foo.open('blah.txt') }
it "is a File" do
expect(a_file).to be_a File
end
end
My question is, will the let() take care of closing the file after the example is run? Or do I need to explicitly close the file somewhere.
Or would something like this be better,
it "is a File" do
Foo.open('blah.txt') do |f|
expect(f).to be_a File
end
end
forgetting about the let() entirely?
I looked at using let and closing files for reference, but I'm still unsure.
Aucun commentaire:
Enregistrer un commentaire