test/vagrant/downloaders/file_test.rb in vagrantup-0.1.4 vs test/vagrant/downloaders/file_test.rb in vagrantup-0.2.0
- old
+ new
@@ -4,29 +4,23 @@
setup do
@downloader, @tempfile = mock_downloader(Vagrant::Downloaders::File)
@uri = "foo.box"
end
- context "downloading" do
- setup do
- @file = mock("file")
- @file.stubs(:read)
- @file.stubs(:eof?).returns(false)
- @downloader.stubs(:open).yields(@file)
+ context "preparing" do
+ should "raise an exception if the file does not exist" do
+ File.expects(:file?).with(@uri).returns(false)
+ assert_raises(Vagrant::Actions::ActionException) {
+ @downloader.prepare(@uri)
+ }
end
+ end
- should "open with the given uri" do
- @downloader.expects(:open).with(@uri).once
- @downloader.download!(@uri, @tempfile)
- end
-
- should "buffer the read from the file and write to the tempfile" do
- data = mock("data")
- write_seq = sequence("write_seq")
- @file.stubs(:eof?).returns(false).in_sequence(write_seq)
- @file.expects(:read).returns(data).in_sequence(write_seq)
- @tempfile.expects(:write).with(data).in_sequence(write_seq)
- @file.stubs(:eof?).returns(true).in_sequence(write_seq)
+ context "downloading" do
+ should "cp the file" do
+ path = '/path'
+ @tempfile.expects(:path).returns(path)
+ FileUtils.expects(:cp).with(@uri, path)
@downloader.download!(@uri, @tempfile)
end
end
end