Sha256: 2101782a3a1f52ab52c451f1ecb8697c6172e4e074532c94b42e26ab358088ff
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
require 'spec_helper' describe FBO::RemoteFile do let(:date) { Date.parse("2013-03-31") } let(:filename) { FBO::RemoteFile.filename_for_date(date) } let(:tmp_dir) { File.join(File.dirname(__FILE__), "..", "fixtures") } let(:ftp) { mock("Net::FTP", login: nil, getbinaryfile: nil, close: nil) } before do Net::FTP.stub(:new).and_return(ftp) end describe "class methods" do describe "for_date" do it "should raise an error if no date is given" do expect { FBO::RemoteFile.for_date(nil) }.to raise_error end it "should return an instance of FBO::RemoteFile" do remote_file = FBO::RemoteFile.for_date(date, tmp_dir: tmp_dir) remote_file.should be_an FBO::RemoteFile end end end context "everything is great" do subject { FBO::RemoteFile.new(filename, tmp_dir: tmp_dir) } it "should attempt to fetch the file via FTP" do ftp.should_receive(:login).ordered ftp.should_receive(:getbinaryfile).ordered ftp.should_receive(:close).ordered subject end it "should be possible to open the file and read its contents" do subject.readline.should_not be_nil end end context "temporary directory doesn't exist" do subject { FBO::RemoteFile.new(filename, tmp_dir: "foo/bar") } before do Dir.stub(:exists?).and_return(false) Dir.stub(:mkdir) File.stub(:new) end it "should create the temporary directory" do Dir.should_receive(:mkdir).with("foo/bar") subject end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fbo-0.0.3 | spec/fbo/remote_file_spec.rb |
fbo-0.0.2 | spec/fbo/remote_file_spec.rb |
fbo-0.0.1 | spec/fbo/remote_file_spec.rb |