spec/groupdocs/signature/envelope_spec.rb in groupdocs-1.9.0 vs spec/groupdocs/signature/envelope_spec.rb in groupdocs-2.0.0
- old
+ new
@@ -16,15 +16,15 @@
end
it 'accepts access credentials hash' do
lambda do
described_class.all!({}, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'allows passing options' do
- lambda { described_class.all!(:page => 1, :count => 3) }.should_not raise_error(ArgumentError)
+ lambda { described_class.all!(:page => 1, :count => 3) }.should_not raise_error()
end
it 'returns array of GroupDocs::Signature::Envelope objects' do
envelopes = described_class.all!
envelopes.should be_an(Array)
@@ -40,15 +40,15 @@
end
it 'accepts access credentials hash' do
lambda do
described_class.for_me!({}, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'allows passing options' do
- lambda { described_class.for_me!(:page => 1, :count => 3) }.should_not raise_error(ArgumentError)
+ lambda { described_class.for_me!(:page => 1, :count => 3) }.should_not raise_error()
end
it 'returns array of GroupDocs::Signature::Envelope objects' do
envelopes = described_class.for_me!
envelopes.should be_an(Array)
@@ -76,22 +76,22 @@
subject.status.should == :in_progress
end
end
describe '#add_recipient!' do
+ before(:each) do
+ mock_api_server(load_json('envelope_recipient_add'))
+ end
+
let(:recipient) do
GroupDocs::Signature::Recipient.new
end
- before(:each) do
- mock_api_server('{ "status": "Ok", "result": {}}')
- end
-
it 'accepts access credentials hash' do
lambda do
subject.add_recipient!(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 recipient is not GroupDocs::Signature::Recipient object' do
lambda { subject.add_recipient!('Recipient') }.should raise_error(ArgumentError)
end
@@ -107,11 +107,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.modify_recipient!(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 recipient is not GroupDocs::Signature::Recipient object' do
lambda { subject.modify_recipient!('Recipient') }.should raise_error(ArgumentError)
end
@@ -126,11 +126,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.delegate_recipient!(old, new, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'raises error if old recipient is not GroupDocs::Signature::Recipient object' do
lambda { subject.delegate_recipient!('Recipient', new) }.should raise_error(ArgumentError)
end
@@ -150,15 +150,15 @@
end
it 'accepts access credentials hash' do
lambda do
subject.fill_field!('test', field, document, recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'can be public' do
- lambda { subject.fill_field!('test', field, document, recipient, :public => true) }.should_not raise_error(ArgumentError)
+ lambda { subject.fill_field!('test', field, document, recipient, :public => true) }.should_not raise_error()
end
it 'raises error if field is not GroupDocs::Signature::Field object' do
lambda { subject.fill_field!('test', 'Field', document, recipient) }.should raise_error(ArgumentError)
end
@@ -174,24 +174,24 @@
it 'returns filled field' do
subject.fill_field!('test', field, document, recipient).should be_a(GroupDocs::Signature::Field)
end
it 'uses signature identifier if field is :signature and GroupDocs::Signature is passed' do
- api = stub(GroupDocs::Api::Request)
- api.stub!(:execute! => { :field => {} })
+ api = double(GroupDocs::Api::Request)
+ api.stub(:execute! => { :field => {} })
GroupDocs::Api::Request.stub(:new => api)
signature = GroupDocs::Signature.new(:id => '123')
api.should_receive(:add_params).with(:signatureId => '123')
field.field_type = :signature
subject.fill_field!(signature, field, document, recipient)
end
it 'converts boolean value to required string if field is :checkbox' do
- api = stub(GroupDocs::Api::Request)
+ api = double(GroupDocs::Api::Request)
options = {}
- api.stub!(:execute! => { :field => {} })
- api.stub!(:options => { :request_body => nil })
+ api.stub(:execute! => { :field => {} })
+ api.stub(:options => { :request_body => nil })
GroupDocs::Api::Request.stub(:new => api)
field.field_type = :checkbox
subject.fill_field!(true, field, document, recipient)
api.options[:request_body].should == 'on'
end
@@ -204,18 +204,14 @@
mock_api_server('{ "status": "Ok", "result": {}}')
end
it 'accepts access credentials hash' do
lambda do
- subject.sign!(recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ subject.sign!(recipient, {}, :client_id => 'client_id', :private_key => 'private_key')
+ end.should_not raise_error()
end
- it 'can be public' do
- lambda { subject.fill_field!('test', field, document, recipient, :public => true) }.should_not raise_error(ArgumentError)
- end
-
it 'raises error if recipient is not GroupDocs::Signature::Recipient object' do
lambda { subject.sign!('Recipient') }.should raise_error(ArgumentError)
end
end
@@ -227,11 +223,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.decline!(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 recipient is not GroupDocs::Signature::Recipient object' do
lambda { subject.decline!('Recipient') }.should raise_error(ArgumentError)
end
@@ -260,11 +256,11 @@
before(:each) do
mock_api_server(File.read('spec/support/files/envelope.zip'))
end
it 'downloads ZIP file' do
- file = stub('file')
+ file = double('file')
subject.stub(:documents! => [])
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
subject.signed_documents!(path)
end
@@ -274,11 +270,11 @@
before(:each) do
mock_api_server(File.read('spec/support/files/resume.pdf'))
end
it 'downloads PDF file' do
- file = stub('file')
+ file = double('file')
subject.stub(:documents! => [1])
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
subject.signed_documents!(path)
end
@@ -288,11 +284,11 @@
before(:each) do
mock_api_server(File.read('spec/support/files/envelope.zip'))
end
it 'downloads ZIP file' do
- file = stub('file')
+ file = double('file')
subject.stub(:documents! => [1, 2])
Object::File.should_receive(:open).with("#{path}/#{subject.name}.zip", 'wb').and_yield(file)
file.should_receive(:write).with(File.read('spec/support/files/envelope.zip'))
subject.signed_documents!(path)
end
@@ -309,19 +305,19 @@
let(:document) { GroupDocs::Document.new(:file => GroupDocs::Storage::File.new) }
it 'accepts access credentials hash' do
lambda do
subject.signed_document!(document, path, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'returns saved file path' do
subject.signed_document!(document, path).should == "#{path}/#{subject.name}.pdf"
end
it 'downloads PDF file' do
- file = stub('file')
+ file = double('file')
Object::File.should_receive(:open).with("#{path}/#{subject.name}.pdf", 'wb').and_yield(file)
file.should_receive(:write).with(File.read('spec/support/files/resume.pdf'))
subject.signed_document!(document, path)
end
end
@@ -332,11 +328,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.logs!(:client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'returns array of GroupDocs::Signature::Envelope::Log objects' do
logs = subject.logs!
logs.should be_an(Array)
@@ -352,11 +348,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.send!(nil, :client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
it 'accepts webhook callback URL and sends it as plain text' do
subject.send! 'http://mywebsite.com'
end
@@ -368,11 +364,11 @@
end
it 'accepts access credentials hash' do
lambda do
subject.archive!(:client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
end
describe '#restart!' do
before(:each) do
@@ -380,9 +376,9 @@
end
it 'accepts access credentials hash' do
lambda do
subject.restart!(:client_id => 'client_id', :private_key => 'private_key')
- end.should_not raise_error(ArgumentError)
+ end.should_not raise_error()
end
end
end