spec/groupdocs/storage/folder_spec.rb in groupdocs-0.2 vs spec/groupdocs/storage/folder_spec.rb in groupdocs-0.2.1
- old
+ new
@@ -1,11 +1,12 @@
require 'spec_helper'
describe GroupDocs::Storage::Folder 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 '.create!' do
before(:each) do
mock_api_server(load_json('folder_create'))
end
@@ -14,12 +15,13 @@
lambda do
described_class.create!('/Test', 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
- -> { described_class.create!('Test') }.should raise_error(ArgumentError)
+ it 'checks that path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('Test')
+ described_class.create!('Test')
end
it 'returns GroupDocs::Storage::Folder object' do
described_class.stub(find!: described_class.new(id: 1))
folder = described_class.create!('/Test')
@@ -72,12 +74,10 @@
it { should respond_to(:name=) }
it { should respond_to(:version) }
it { should respond_to(:version=) }
it { should respond_to(:type) }
it { should respond_to(:type=) }
- it { should respond_to(:access) }
- it { should respond_to(:access=) }
describe '#created_on' do
it 'returns converted to Time object Unix timestamp' do
subject.created_on = 1330450135
subject.created_on.should be_a(Time)
@@ -89,37 +89,33 @@
subject.modified_on = 1330450135
subject.modified_on.should be_a(Time)
end
end
- describe '#access' do
- it 'returns converted to human-readable format access mode' do
- subject.should_receive(:parse_access_mode).with(0).and_return(:private)
- subject.access = 0
- subject.access.should == :private
+ describe '#move!' do
+ before(:each) do
+ mock_api_server(load_json('folder_move'))
end
- end
- describe '#move!' do
it 'accepts access credentials hash' do
lambda do
subject.move!('/Test', 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!('Test2') }.should raise_error(ArgumentError)
+ it 'checks that path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('Test1')
+ subject.move!('Test1')
end
it 'sends "Groupdocs-Move" header' do
mock_api_server(load_json('folder_move'), :'Groupdocs-Move' => 'Test1')
subject.stub(name: 'Test1')
subject.move!('/Test2')
end
it 'returns moved to folder path' do
- mock_api_server(load_json('folder_move'))
moved = subject.move!('/Test2')
moved.should be_a(String)
moved.should == '/Test2'
end
end
@@ -143,27 +139,31 @@
renamed.should == 'Test2'
end
end
describe '#copy!' do
+ before(:each) do
+ mock_api_server(load_json('folder_move'))
+ end
+
it 'accepts access credentials hash' do
lambda do
subject.copy!('/Test2', 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!('Test2') }.should raise_error(ArgumentError)
+ it 'checks that path starts with /' do
+ GroupDocs::Api::Helpers::Path.should_receive(:verify_starts_with_root).with('Test2')
+ subject.copy!('Test2')
end
it 'sends "Groupdocs-Copy" header' do
mock_api_server(load_json('folder_move'), :'Groupdocs-Copy' => 'Test1')
subject.stub(name: 'Test1')
subject.copy!('/Test2')
end
it 'returns moved to folder path' do
- mock_api_server(load_json('folder_move'))
moved = subject.copy!('/Test2')
moved.should be_a(String)
moved.should == '/Test2'
end
end