spec/groupdocs/job_spec.rb in groupdocs-0.3.11 vs spec/groupdocs/job_spec.rb in groupdocs-1.0.0

- old
+ new

@@ -29,10 +29,26 @@ job.should be_a(GroupDocs::Job) end end end + describe '.get!' do + before(:each) do + mock_api_server(load_json('job_get')) + end + + it 'accepts access credentials hash' do + lambda do + described_class.get!(1, client_id: 'client_id', private_key: 'private_key') + end.should_not raise_error(ArgumentError) + end + + it 'returns GroupDocs::Job object' do + described_class.get!(1).should be_a(GroupDocs::Job) + end + end + describe '.create!' do before(:each) do mock_api_server(load_json('job_create')) end @@ -64,10 +80,16 @@ end end it { should respond_to(:id) } it { should respond_to(:id=) } + it { should respond_to(:guid) } + it { should respond_to(:guid=) } + it { should respond_to(:name) } + it { should respond_to(:name=) } + it { should respond_to(:priority) } + it { should respond_to(:priority=) } it { should respond_to(:actions) } it { should respond_to(:actions=) } it { should respond_to(:email_results) } it { should respond_to(:email_results=) } it { should respond_to(:url_only) } @@ -138,10 +160,15 @@ documents.should be_an(Array) documents.each do |document| document.should be_a(GroupDocs::Document) end end + + it 'returns empty array if null is returned instead of inputs array' do + mock_api_server('{ "status": "Ok", "result": {}}') + subject.documents!.should be_empty + end end describe '#add_document!' do before(:each) do mock_api_server(load_json('job_file_add')) @@ -167,9 +194,25 @@ -> { subject.add_document!('Document') }.should raise_error(ArgumentError) end it 'returns document ID' do subject.add_document!(document).should be_an(Integer) + end + end + + describe '#delete_document!' do + before(:each) do + mock_api_server('{ "result": {}, "status": "Ok" }') + end + + it 'accepts access credentials hash' do + lambda do + subject.delete_document!('a9ufg8s7dfgsdf', client_id: 'client_id', private_key: 'private_key') + end.should_not raise_error(ArgumentError) + end + + it 'returns empty hash' do + subject.delete_document!('a9ufg8s7dfgsdf').should be_empty end end describe '#add_datasource!' do let(:document) do