spec/groupdocs/storage/file_spec.rb in groupdocs-1.5.5 vs spec/groupdocs/storage/file_spec.rb in groupdocs-1.5.6
- old
+ new
@@ -43,10 +43,28 @@
it 'returns GroupDocs::Storage::File object' do
described_class.upload!(__FILE__).should be_a(GroupDocs::Storage::File)
end
end
+ describe '.decompress!' do
+ before(:each) do
+ mock_api_server(load_json('file_upload'))
+ end
+
+ it 'accepts access credentials hash' do
+ lambda do
+ described_class.decompress!(__FILE__, {}, :client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error(ArgumentError)
+ end
+
+ it 'accepts options hash' do
+ lambda do
+ described_class.decompress!(__FILE__, :path => 'folder1', :archiveType => 'zip')
+ end.should_not raise_error(ArgumentError)
+ end
+ end
+
describe '.upload_web!' do
before(:each) do
mock_api_server(load_json('file_upload'))
end
@@ -59,10 +77,26 @@
it 'returns GroupDocs::Storage::File object' do
described_class.upload_web!('http://www.google.com').should be_a(GroupDocs::Storage::File)
end
end
+ describe '.upload_google!' do
+ before(:each) do
+ mock_api_server(load_json('file_upload'))
+ end
+
+ it 'accepts access credentials hash' do
+ lambda do
+ described_class.upload_google!('path', 'http://www.google.com', :client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error(ArgumentError)
+ end
+
+ it 'returns GroupDocs::Storage::File object' do
+ described_class.upload_google!('path', 'http://www.google.com').should be_a(GroupDocs::Storage::File)
+ end
+ end
+
it { should have_accessor(:id) }
it { should have_accessor(:guid) }
it { should have_accessor(:known) }
it { should have_accessor(:size) }
it { should have_accessor(:thumbnail) }
@@ -146,10 +180,36 @@
it 'returns saved file path' do
subject.download!(path).should == "#{path}/resume.pdf"
end
end
+ describe '#download!' do
+ before(:each) do
+ mock_api_server(File.read('spec/support/files/resume.pdf'))
+ subject.stub(:name => 'resume.pdf')
+ end
+
+ let(:path) { Dir.tmpdir }
+
+ it 'accepts access credentials hash' do
+ lambda do
+ subject.download!(path, :client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error(ArgumentError)
+ end
+
+ it 'downloads file to given path' do
+ file = stub('file')
+ Object::File.should_receive(:open).with("#{path}/resume.pdf", 'wb').and_yield(file)
+ file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
+ subject.download!(path)
+ end
+
+ it 'returns saved file path' do
+ subject.download!(path).should == "#{path}/resume.pdf"
+ end
+ end
+
describe '#move!' do
before(:each) do
mock_api_server(load_json('file_move'))
end
@@ -273,9 +333,17 @@
describe '#move_to_trash!' do
it 'accepts access credentials hash' do
lambda do
subject.move_to_trash!(:client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error(ArgumentError)
+ end
+ end
+
+ describe '#restore_to_trash!' do
+ it 'accepts access credentials hash' do
+ lambda do
+ subject.restore_to_trash!('path', :client_id => 'client_id', :private_key => 'private_key')
end.should_not raise_error(ArgumentError)
end
end
describe '#to_document' do