spec/sftp_spec.rb in carrierwave-ftp-0.2.8 vs spec/sftp_spec.rb in carrierwave-ftp-0.3.0

- old
+ new

@@ -42,20 +42,20 @@ @stored = @storage.store!(@file) end describe 'after upload' do before do - sftp = double(:sftp_connection) - Net::SFTP.stub(:start).and_return(sftp) - sftp.stub(:mkdir_p!) - sftp.stub(:upload!) - sftp.stub(:close_channel) + @sftp = double(:sftp_connection) + Net::SFTP.stub(:start).and_return(@sftp) + @sftp.stub(:mkdir_p!) + @sftp.stub(:upload!) + @sftp.stub(:close_channel) @stored = @storage.store!(@file) end - it "should use the calculated URL when retrieving a file" do - @stored.should_receive(:url).and_return('http://example.com/') + it "should use the ftp when retrieving a file" do + @sftp.should_receive(:download!).with(@stored.send(:full_path), kind_of(Tempfile)) @stored.read end it "returns a url based on directory" do @stored.url.should == 'http://testcarrierwave.dev/uploads/test.jpg' @@ -90,16 +90,16 @@ @sftp.should_receive(:stat!).with('/home/test_user/public_html/uploads/test.jpg').and_return(Struct.new(:size).new(14)) @stored.size.should == 14 end it "returns to_file" do - @stored.should_receive(:file).and_return(Struct.new(:body).new('some content')) - @stored.to_file.size.should == 'some content'.length + @sftp.should_receive(:download!).with(@stored.send(:full_path), kind_of(Tempfile)) + @stored.to_file.size.should == 0 end it "returns the content of the file" do - @stored.should_receive(:file).and_return(Struct.new(:body).new('some content')) - @stored.read.should == 'some content' + @sftp.should_receive(:download!).with(@stored.send(:full_path), kind_of(Tempfile)) + @stored.read.should == '' end it "returns the content_type of the file" do @stored.should_receive(:file).and_return(Struct.new(:content_type).new('some/type')) @stored.content_type.should == 'some/type'