spec/support/shared_examples/signature/shared/field_methods.rb in groupdocs-1.9.0 vs spec/support/shared_examples/signature/shared/field_methods.rb in groupdocs-2.0.0
- old
+ new
@@ -16,21 +16,13 @@
mock_api_server(load_json('signature_fields_get'))
end
it 'accepts access credentials hash' do
lambda do
- subject.fields!(*args, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ subject.fields!(document, recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error()
end
-
- it 'returns array of GroupDocs::Signature::Field objects' do
- fields = subject.fields!(*args)
- fields.should be_an(Array)
- fields.each do |field|
- field.should be_a(GroupDocs::Signature::Field)
- end
- end
end
describe '#add_field!' do
let(:field) { GroupDocs::Signature::Field.new(:location => { :location_x => 0.1, :page => 1 }) }
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
@@ -41,11 +33,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.add_field!(field, *args, { :force_new_field => false }, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'raises error if field is not GroupDocs::Signature::Field object' do
lambda { subject.add_field!('Field', *args) }.should raise_error(ArgumentError)
end
@@ -77,32 +69,36 @@
subject.add_field!(field, *args, :force_new_field => false)
end
end
describe '#modify_field!' do
- let(:field) { GroupDocs::Signature::Field.new }
- let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
+ let(:field) { GroupDocs::Signature::Field.new(:locations=>[GroupDocs::Signature::Field::Location.new]) }
+ let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
let(:recipient) { GroupDocs::Signature::Recipient.new }
before(:each) do
mock_api_server(load_json('signature_field_add'))
end
it 'accepts access credentials hash' do
lambda do
subject.modify_field!(field, document, recipient, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'raises error if field is not GroupDocs::Signature::Field object' do
lambda { subject.modify_field!('Field', document, recipient) }.should raise_error(ArgumentError)
end
it 'raises error if document is not GroupDocs::Document object' do
lambda { subject.modify_field!(field, 'Document', recipient) }.should raise_error(ArgumentError)
end
+ it 'raises error if field is not GroupDocs::Signature::Recipient object' do
+ lambda { subject.modify_field!(field, document, 'Recipient') }.should raise_error(ArgumentError)
+ end
+
it 'uses field and first field location as payload' do
payload = {}
location = {}
locations = [location]
field.should_receive(:to_hash).and_return(payload)
@@ -131,11 +127,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.assign_field!(field, document, assign_from, assign_to, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'raises error if field is not GroupDocs::Signature::Field object' do
lambda { subject.assign_field!('Field', document, assign_from, assign_to) }.should raise_error(ArgumentError)
end
@@ -168,11 +164,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.delete_field!(field, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
end
describe '#modify_field_location!' do
let(:field) { GroupDocs::Signature::Field.new }
@@ -193,11 +189,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.modify_field_location!(location, field, *args, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
end
describe '#delete_field_location!' do
let(:field) { GroupDocs::Signature::Field.new }
@@ -216,9 +212,9 @@
end
it 'accepts access credentials hash' do
lambda do
subject.delete_field_location!(location, field, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
end
end