spec/groupdocs/storage/file_spec.rb in groupdocs-0.2 vs spec/groupdocs/storage/file_spec.rb in groupdocs-0.2.1
- old
+ new
@@ -1,11 +1,12 @@
require 'spec_helper'
describe GroupDocs::Storage::File do
it_behaves_like GroupDocs::Api::Entity
- include_examples GroupDocs::Api::Sugar::Lookup
+ include_examples GroupDocs::Extensions::Lookup
+ include_examples GroupDocs::Api::Helpers::AccessMode
describe 'DOCUMENT_TYPES' do
it 'contains hash of document types' do
described_class::DOCUMENT_TYPES.should == {
undefined: -1,
@@ -28,18 +29,18 @@
lambda do
described_class.upload!(__FILE__, '/upload_path', client_id: 'client_id', private_key: 'private_key')
end.should_not raise_error(ArgumentError)
end
- it 'raises error if upload path does not start with /' do
- -> { described_class.upload!('test', 'upload_path') }.should raise_error(ArgumentError)
+ it 'checks that upload path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('/upload_path')
+ described_class.upload!(__FILE__, '/upload_path')
end
it 'appends filename to upload path if it is not passed' do
- upload_path = '/upload_path'
- upload_path.should_receive(:<<).with("/#{File.basename(__FILE__)}")
- described_class.upload!(__FILE__, upload_path)
+ GroupDocs::Api::Helpers::Path.should_receive(:append_file_name).with('/upload_path', __FILE__)
+ described_class.upload!(__FILE__, '/upload_path')
end
it 'returns GroupDocs::Storage::File object' do
described_class.upload!(__FILE__).should be_a(GroupDocs::Storage::File)
end
@@ -67,12 +68,10 @@
it { should respond_to(:version=) }
it { should respond_to(:type) }
it { should respond_to(:type=) }
it { should respond_to(:file_type) }
it { should respond_to(:file_type=) }
- it { should respond_to(:access) }
- it { should respond_to(:access=) }
it { should respond_to(:path) }
it { should respond_to(:path=) }
it 'is compatible with response JSON' do
subject.should respond_to(:adj_name=)
@@ -151,31 +150,29 @@
lambda do
subject.move!('/resume.pdf', client_id: 'client_id', private_key: 'private_key')
end.should_not raise_error(ArgumentError)
end
- it 'raises error if path does not start with /' do
- -> { subject.move!('resume2.pdf') }.should raise_error(ArgumentError)
+ it 'checks that path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('/resume.pdf')
+ subject.move!('/resume.pdf')
end
+ it 'appends filename to move to path if it is not passed' do
+ GroupDocs::Api::Helpers::Path.should_receive(:append_file_name).with('/Folder', subject.name)
+ subject.move!('/Folder')
+ end
+
it 'sends "Groupdocs-Move" header' do
mock_api_server(load_json('file_move'), :'Groupdocs-Move' => '123')
subject.stub(id: 123)
subject.move!('/resume2.pdf')
end
it 'returns moved to file' do
subject.move!('/resume2.pdf').should be_a(GroupDocs::Storage::File)
end
-
- it 'appends filename to move to path if it is not passed' do
- path = '/Folder'
- name = File.basename(__FILE__)
- subject.stub(name: name)
- path.should_receive(:<<).with("/#{name}")
- subject.move!(path)
- end
end
describe '#rename!' do
before(:each) do
subject.path = '/'
@@ -202,29 +199,27 @@
lambda do
subject.copy!('/resume.pdf', client_id: 'client_id', private_key: 'private_key')
end.should_not raise_error(ArgumentError)
end
- it 'raises error if path does not start with /' do
- -> { subject.copy!('resume2.pdf') }.should raise_error(ArgumentError)
+ it 'checks that path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('resume.pdf')
+ subject.copy!('resume.pdf')
end
+ it 'appends filename to move to path if it is not passed' do
+ GroupDocs::Api::Helpers::Path.should_receive(:append_file_name).with('/Folder', subject.name)
+ subject.copy!('/Folder')
+ end
+
it 'sends "Groupdocs-Copy" header' do
mock_api_server(load_json('file_copy'), :'Groupdocs-Copy' => '123')
subject.stub(id: 123)
subject.copy!('/resume2.pdf')
end
it 'returns copied to file' do
subject.copy!('/resume2.pdf').should be_a(GroupDocs::Storage::File)
- end
-
- it 'appends filename to copy to path if it is not passed' do
- path = '/Folder'
- name = File.basename(__FILE__)
- subject.stub(name: name)
- path.should_receive(:<<).with("/#{name}")
- subject.copy!(path)
end
end
describe '#compress!' do
before(:each) do