hello_sign 0.6.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/lib/hello_sign/client.rb +2 -2
  2. data/lib/hello_sign/parameters/reusable_form_signature_request.rb +9 -9
  3. data/lib/hello_sign/parameters/signature_request.rb +15 -15
  4. data/lib/hello_sign/parameters/unclaimed_draft.rb +7 -7
  5. data/lib/hello_sign/proxy/account.rb +1 -1
  6. data/lib/hello_sign/proxy/reusable_form.rb +10 -9
  7. data/lib/hello_sign/proxy/settings.rb +1 -1
  8. data/lib/hello_sign/proxy/signature_request.rb +13 -12
  9. data/lib/hello_sign/proxy/team.rb +4 -4
  10. data/lib/hello_sign/proxy/unclaimed_draft.rb +1 -1
  11. data/lib/hello_sign/proxy.rb +4 -4
  12. data/lib/hello_sign/upload_io.rb +56 -0
  13. data/lib/hello_sign/version.rb +1 -1
  14. data/lib/hello_sign.rb +1 -1
  15. data/spec/helper.rb +0 -2
  16. data/spec/integration/account_spec.rb +4 -4
  17. data/spec/integration/hello_sign_spec.rb +2 -2
  18. data/spec/integration/helper.rb +6 -1
  19. data/spec/integration/reusable_form_spec.rb +16 -20
  20. data/spec/integration/signature_request_spec.rb +52 -57
  21. data/spec/integration/team_spec.rb +8 -8
  22. data/spec/integration/unclaimed_draft_spec.rb +3 -3
  23. data/spec/shared_examples/proxy.rb +15 -5
  24. data/spec/unit/client_spec.rb +3 -3
  25. data/spec/unit/middleware/raise_error_spec.rb +1 -1
  26. data/spec/unit/parameters/reusable_form_signature_request_spec.rb +17 -17
  27. data/spec/unit/parameters/signature_request_spec.rb +25 -20
  28. data/spec/unit/parameters/unclaimed_draft_spec.rb +12 -11
  29. data/spec/unit/proxy/account_spec.rb +6 -6
  30. data/spec/unit/proxy/reusable_form_spec.rb +13 -12
  31. data/spec/unit/proxy/settings_spec.rb +3 -3
  32. data/spec/unit/proxy/signature_request_spec.rb +29 -32
  33. data/spec/unit/proxy/team_spec.rb +12 -12
  34. data/spec/unit/proxy/unclaimed_draft_spec.rb +1 -1
  35. data/spec/unit/upload_io_spec.rb +60 -0
  36. metadata +19 -15
@@ -6,69 +6,69 @@ describe HelloSign do
6
6
  let(:text_file_io) { File.new('spec/fixtures/test.txt') }
7
7
  let(:image_io) { File.new('spec/fixtures/test.jpg') }
8
8
 
9
- before do
10
- stub_post_with_auth('/signature_request/send')
9
+ before { stub_post_with_auth('/signature_request/send') }
10
+
11
+ example do
11
12
  HelloSign.signature_request.deliver do |request|
12
13
  request.title = 'Lease'
13
14
  request.subject = 'Sign this'
14
15
  request.message = 'You must sign this.'
15
16
  request.ccs = ['lawyer@lawfirm.com', 'spouse@family.com']
16
17
  request.signers = [
17
- {:name => 'Jack', :email_address => 'jack@hill.com'},
18
- {:name => 'Jill', :email_address => 'jill@hill.com'}
18
+ {name: 'Jack', email_address: 'jack@hill.com'},
19
+ {name: 'Jill', email_address: 'jill@hill.com'}
19
20
  ]
20
21
  request.files = [
21
- {:name => 'test.txt', :io => text_file_io, :mime => 'text/plain'},
22
- {:name => 'test.jpg', :io => image_io, :mime => 'image/jpeg'}
22
+ {filename: 'test.txt', io: text_file_io, mime: 'text/plain'},
23
+ {filename: 'spec/fixtures/test.txt', mime: 'text/xml'},
24
+ {filename: 'spec/fixtures/test.jpg'},
25
+ {io: image_io, mime: 'image/jpeg'}
23
26
  ]
24
27
  end
25
- end
26
28
 
27
- it "sends a signature request to the HelloSign API" do
28
29
  expect(a_post_with_auth('/signature_request/send')
29
- .with(:headers => {'Content-Type' => /multipart\/form-data/}, :body => /This is a test upload file\./)
30
+ .with(headers: {'Content-Type' => /multipart\/form-data/}, body: /This is a test upload file\./)
30
31
  ).to have_been_made
31
32
  end
32
33
  end
33
34
 
34
35
  context "when using a reusable form" do
35
- before do
36
- stub_post_with_auth('/signature_request/send_with_reusable_form')
37
- HelloSign.signature_request.deliver(:form => 'form_id') do |request|
36
+ before { stub_post_with_auth('/signature_request/send_with_reusable_form') }
37
+
38
+ example do
39
+ HelloSign.signature_request.deliver(form: 'form_id') do |request|
38
40
  request.title = 'Lease'
39
41
  request.subject = 'Sign this'
40
42
  request.message = 'You must sign this.'
41
43
  request.ccs = [
42
- {:email_address => 'lawyer@lawfirm.com', :role => 'lawyer'},
43
- {:email_address => 'accountant@llc.com', :role => 'accountant'}
44
+ {email_address: 'lawyer@lawfirm.com', role: 'lawyer'},
45
+ {email_address: 'accountant@llc.com', role: 'accountant'}
44
46
  ]
45
47
  request.signers = [
46
- {:name => 'Jack', :email_address => 'jack@hill.com', :role => 'consultant'},
47
- {:name => 'Jill', :email_address => 'jill@hill.com', :role => 'client'}
48
+ {name: 'Jack', email_address: 'jack@hill.com', role: 'consultant'},
49
+ {name: 'Jill', email_address: 'jill@hill.com', role: 'client'}
48
50
  ]
49
51
  request.custom_fields = [
50
- {:name => 'cost', :value => '$20,000'},
51
- {:name => 'time', :value => 'two weeks'}
52
+ {name: 'cost', value: '$20,000'},
53
+ {name: 'time', value: 'two weeks'}
52
54
  ]
53
55
  end
54
- end
55
56
 
56
- it "sends a signature request using a reusable form to the HelloSign API" do
57
57
  expect(a_post_with_auth('/signature_request/send_with_reusable_form')
58
- .with(:body => {
59
- :reusable_form_id => 'form_id',
60
- :title => 'Lease',
61
- :subject => 'Sign this',
62
- :message => 'You must sign this.',
63
- :ccs => {
64
- 'lawyer' => {:email_address => 'lawyer@lawfirm.com'},
65
- 'accountant' => {:email_address => 'accountant@llc.com'}
58
+ .with(body: {
59
+ reusable_form_id: 'form_id',
60
+ title: 'Lease',
61
+ subject: 'Sign this',
62
+ message: 'You must sign this.',
63
+ ccs: {
64
+ 'lawyer' => {email_address: 'lawyer@lawfirm.com'},
65
+ 'accountant' => {email_address: 'accountant@llc.com'}
66
66
  },
67
- :signers => {
68
- 'consultant' => {:name => 'Jack', :email_address => 'jack@hill.com'},
69
- 'client' => {:name => 'Jill', :email_address => 'jill@hill.com'}
67
+ signers: {
68
+ 'consultant' => {name: 'Jack', email_address: 'jack@hill.com'},
69
+ 'client' => {name: 'Jill', email_address: 'jill@hill.com'}
70
70
  },
71
- :custom_fields => {
71
+ custom_fields: {
72
72
  'cost' => '$20,000',
73
73
  'time' => 'two weeks'
74
74
  }
@@ -79,58 +79,53 @@ describe HelloSign do
79
79
  end
80
80
 
81
81
  context "when fetching a signature request" do
82
- before do
83
- stub_get_with_auth('/signature_request/request_id')
84
- HelloSign.signature_request.status('request_id')
85
- end
82
+ before { stub_get_with_auth('/signature_request/request_id') }
83
+
84
+ example do
85
+ HelloSign.signature_request('request_id').status
86
86
 
87
- it "fetches the signature request information from the HelloSign API" do
88
87
  expect(a_get_with_auth('/signature_request/request_id')).to have_been_made
89
88
  end
90
89
  end
91
90
 
92
91
  context "when getting a list of signature requests" do
93
- before do
94
- stub_get_with_auth('/signature_request/list?page=1')
92
+ before { stub_get_with_auth('/signature_request/list?page=1') }
93
+
94
+ example do
95
95
  HelloSign.signature_request.list
96
- end
97
96
 
98
- it "fetches a list of signature requests from the HelloSign API" do
99
97
  expect(a_get_with_auth('/signature_request/list?page=1')).to have_been_made
100
98
  end
101
99
  end
102
100
 
103
101
  context "when sending a signature request reminder" do
104
- before do
105
- stub_post_with_auth('/signature_request/remind/request_id')
106
- HelloSign.signature_request.remind('request_id', :email => 'john@johnson.com')
107
- end
102
+ before { stub_post_with_auth('/signature_request/remind/request_id') }
103
+
104
+ example do
105
+ HelloSign.signature_request('request_id').remind(email: 'john@johnson.com')
108
106
 
109
- it "sends a reminder request to the HelloSign API" do
110
107
  expect(a_post_with_auth('/signature_request/remind/request_id')
111
- .with(:body => {:email_address => 'john@johnson.com'})
108
+ .with(body: {email_address: 'john@johnson.com'})
112
109
  ).to have_been_made
113
110
  end
114
111
  end
115
112
 
116
113
  context "when canceling a signature request" do
117
- before do
118
- stub_post_with_auth('/signature_request/cancel/request_id')
119
- HelloSign.signature_request.cancel('request_id')
120
- end
114
+ before { stub_post_with_auth('/signature_request/cancel/request_id') }
115
+
116
+ example do
117
+ HelloSign.signature_request('request_id').cancel
121
118
 
122
- it "sends a signature request cancellation to the HelloSign API" do
123
119
  expect(a_post_with_auth('/signature_request/cancel/request_id')).to have_been_made
124
120
  end
125
121
  end
126
122
 
127
123
  context "when fetching a final copy of a signature request" do
128
- before do
129
- stub_get_with_auth('/signature_request/final_copy/request_id')
130
- HelloSign.signature_request.final_copy('request_id')
131
- end
124
+ before { stub_get_with_auth('/signature_request/final_copy/request_id') }
125
+
126
+ example do
127
+ HelloSign.signature_request('request_id').final_copy
132
128
 
133
- it "fetches a final copy of the signature request from the HelloSign API" do
134
129
  expect(a_get_with_auth('/signature_request/final_copy/request_id')).to have_been_made
135
130
  end
136
131
  end
@@ -5,10 +5,10 @@ describe HelloSign do
5
5
  before { stub_post_with_auth('/team/create') }
6
6
 
7
7
  example do
8
- HelloSign.team.create(:name => 'The Browncoats')
8
+ HelloSign.team.create(name: 'The Browncoats')
9
9
 
10
10
  expect(a_post_with_auth('/team/create')
11
- .with(:body => {:name => 'The Browncoats'}))
11
+ .with(body: {name: 'The Browncoats'}))
12
12
  .to have_been_made
13
13
  end
14
14
  end
@@ -28,10 +28,10 @@ describe HelloSign do
28
28
  before { stub_post_with_auth('/team') }
29
29
 
30
30
  example do
31
- HelloSign.team.update(:name => 'The Bluecoats')
31
+ HelloSign.team.update(name: 'The Bluecoats')
32
32
 
33
33
  expect(a_post_with_auth('/team')
34
- .with(:name => 'The Bluecoats'))
34
+ .with(name: 'The Bluecoats'))
35
35
  .to have_been_made
36
36
  end
37
37
  end
@@ -51,10 +51,10 @@ describe HelloSign do
51
51
  before { stub_post_with_auth('/team/add_member') }
52
52
 
53
53
  example do
54
- HelloSign.team.add_member(:email => 'bob@smith.com')
54
+ HelloSign.team.add_member(email: 'bob@smith.com')
55
55
 
56
56
  expect(a_post_with_auth('/team/add_member')
57
- .with(:email => 'bob@smith.com'))
57
+ .with(email: 'bob@smith.com'))
58
58
  .to have_been_made
59
59
  end
60
60
  end
@@ -63,10 +63,10 @@ describe HelloSign do
63
63
  before { stub_post_with_auth('/team/remove_member') }
64
64
 
65
65
  example do
66
- HelloSign.team.remove_member(:email => 'bob@smith.com')
66
+ HelloSign.team.remove_member(email: 'bob@smith.com')
67
67
 
68
68
  expect(a_post_with_auth('/team/remove_member')
69
- .with(:email => 'bob@smith.com'))
69
+ .with(email: 'bob@smith.com'))
70
70
  .to have_been_made
71
71
  end
72
72
  end
@@ -10,13 +10,13 @@ describe HelloSign do
10
10
  example do
11
11
  HelloSign.unclaimed_draft.create do |draft|
12
12
  draft.files = [
13
- {:name => 'test.txt', :io => text_io, :mime => 'text/plain'},
14
- {:name => 'test.jpg', :io => image_io, :mime => 'image/jpeg'}
13
+ {name: 'test.txt', io: text_io, mime: 'text/plain'},
14
+ {name: 'test.jpg', io: image_io, mime: 'image/jpeg'}
15
15
  ]
16
16
  end
17
17
 
18
18
  expect(a_post_with_auth('/unclaimed_draft/create')
19
- .with(:headers => {'Content-Type' => /multipart\/form-data/}, :body => /This is a test upload file\./)
19
+ .with(headers: {'Content-Type' => /multipart\/form-data/}, body: /This is a test upload file\./)
20
20
  ).to have_been_made
21
21
  end
22
22
  end
@@ -14,25 +14,35 @@ shared_examples_for 'a proxy' do
14
14
  describe "#signature_request" do
15
15
  before { client.signature_request_proxy_source = proxy_source }
16
16
 
17
- it "returns an signature request proxy" do
18
- proxy_source.should_receive(:new).with(client).and_return(proxy)
17
+ it "returns a signature request proxy" do
18
+ proxy_source.should_receive(:new).with(client, nil).and_return(proxy)
19
19
  expect(client.signature_request).to eq proxy
20
20
  end
21
+
22
+ it "passes on an optional signature request ID" do
23
+ proxy_source.should_receive(:new).with(client, 'signature_request_id')
24
+ client.signature_request('signature_request_id')
25
+ end
21
26
  end
22
27
 
23
28
  describe "#reusable_form" do
24
29
  before { client.reusable_form_proxy_source = proxy_source }
25
30
 
26
- it "returns an reusable form proxy" do
27
- proxy_source.should_receive(:new).with(client).and_return(proxy)
31
+ it "returns a reusable form proxy" do
32
+ proxy_source.should_receive(:new).with(client, nil).and_return(proxy)
28
33
  expect(client.reusable_form).to eq proxy
29
34
  end
35
+
36
+ it "passes on an optional reusable form ID" do
37
+ proxy_source.should_receive(:new).with(client, 'reusable_form_id')
38
+ client.reusable_form('reusable_form_id')
39
+ end
30
40
  end
31
41
 
32
42
  describe "#team" do
33
43
  before { client.team_proxy_source = proxy_source }
34
44
 
35
- it "returns an team proxy" do
45
+ it "returns a team proxy" do
36
46
  proxy_source.should_receive(:new).with(client).and_return(proxy)
37
47
  expect(client.team).to eq proxy
38
48
  end
@@ -45,17 +45,17 @@ describe HelloSign::Client do
45
45
  end
46
46
 
47
47
  context "when a hash is passed to the constructor" do
48
- subject(:hs_client) { HelloSign::Client.new(:email_address => email_address, :password => password) }
48
+ subject(:hs_client) { HelloSign::Client.new(email_address: email_address, password: password) }
49
49
 
50
50
  its(:email_address) { should eq email_address }
51
51
  its(:password) { should eq password }
52
52
 
53
53
  it "raises an exception if an email address is not provided" do
54
- expect { HelloSign::Client.new(:password => 'space') }.to raise_error ArgumentError
54
+ expect { HelloSign::Client.new(password: 'space') }.to raise_error ArgumentError
55
55
  end
56
56
 
57
57
  it "raises an exception if a password is not provided" do
58
- expect { HelloSign::Client.new(:email_address => 'david@bowman.com') }.to raise_error ArgumentError
58
+ expect { HelloSign::Client.new(email_address: 'david@bowman.com') }.to raise_error ArgumentError
59
59
  end
60
60
  end
61
61
  end
@@ -21,7 +21,7 @@ describe HelloSign::Middleware::RaiseError do
21
21
  private
22
22
 
23
23
  def call_with_error(error)
24
- env = {:body => {:error => {:error_name => error}}}
24
+ env = {body: {error: {error_name: error}}}
25
25
  middleware.call(env)
26
26
  end
27
27
 
@@ -11,34 +11,34 @@ describe HelloSign::Parameters::ReusableFormSignatureRequest do
11
11
  request_parameters.subject = 'Sign this'
12
12
  request_parameters.message = 'You must sign this.'
13
13
  request_parameters.ccs = [
14
- {:email_address => 'lawyer@lawfirm.com', :role => 'lawyer'},
15
- {:email_address => 'accountant@llc.com', :role => 'accountant'}
14
+ {email_address: 'lawyer@lawfirm.com', role: 'lawyer'},
15
+ {email_address: 'accountant@llc.com', role: 'accountant'}
16
16
  ]
17
17
  request_parameters.signers = [
18
- {:name => 'Jack', :email_address => 'jack@hill.com', :role => 'consultant'},
19
- {:name => 'Jill', :email_address => 'jill@hill.com', :role => 'client'}
18
+ {name: 'Jack', email_address: 'jack@hill.com', role: 'consultant'},
19
+ {name: 'Jill', email_address: 'jill@hill.com', role: 'client'}
20
20
  ]
21
21
  request_parameters.custom_fields = [
22
- {:name => 'cost', :value => '$20,000'},
23
- {:name => 'time', :value => 'two weeks'}
22
+ {name: 'cost', value: '$20,000'},
23
+ {name: 'time', value: 'two weeks'}
24
24
  ]
25
25
  end
26
26
 
27
27
  it "returns formatted parameters" do
28
28
  expected = {
29
- :reusable_form_id => 'form_id',
30
- :title => 'Lease',
31
- :subject => 'Sign this',
32
- :message => 'You must sign this.',
33
- :ccs => {
34
- 'lawyer' => {:email_address => 'lawyer@lawfirm.com'},
35
- 'accountant' => {:email_address => 'accountant@llc.com'}
29
+ reusable_form_id: 'form_id',
30
+ title: 'Lease',
31
+ subject: 'Sign this',
32
+ message: 'You must sign this.',
33
+ ccs: {
34
+ 'lawyer' => {email_address: 'lawyer@lawfirm.com'},
35
+ 'accountant' => {email_address: 'accountant@llc.com'}
36
36
  },
37
- :signers => {
38
- 'consultant' => {:name => 'Jack', :email_address => 'jack@hill.com'},
39
- 'client' => {:name => 'Jill', :email_address => 'jill@hill.com'}
37
+ signers: {
38
+ 'consultant' => {name: 'Jack', email_address: 'jack@hill.com'},
39
+ 'client' => {name: 'Jill', email_address: 'jill@hill.com'}
40
40
  },
41
- :custom_fields => {
41
+ custom_fields: {
42
42
  'cost' => '$20,000',
43
43
  'time' => 'two weeks'
44
44
  }
@@ -4,20 +4,24 @@ require 'hello_sign/parameters/signature_request'
4
4
  describe HelloSign::Parameters::SignatureRequest do
5
5
  describe "#formatted" do
6
6
  let(:request_parameters) { HelloSign::Parameters::SignatureRequest.new }
7
+ let(:upload_io_source) { double('upload IO source') }
7
8
  let(:text_file) { double('text file') }
8
9
  let(:image_file) { double('image file') }
10
+
11
+ before { request_parameters.upload_io_source = upload_io_source }
12
+
9
13
  context "when all required arguments are set" do
10
14
  let(:expected) do
11
15
  {
12
- :title => 'Lease',
13
- :subject => 'Sign this',
14
- :message => 'You must sign this.',
15
- :cc_email_addresses => ['lawyer@lawfirm.com', 'spouse@family.com'], # BUGBUG: should have explicit indexes
16
- :signers => {
17
- 0 => {:name => 'Jack', :email_address => 'jack@hill.com', :order => 0},
18
- 1 => {:name => 'Jill', :email_address => 'jill@hill.com', :order => 1}
16
+ title: 'Lease',
17
+ subject: 'Sign this',
18
+ message: 'You must sign this.',
19
+ cc_email_addresses: ['lawyer@lawfirm.com', 'spouse@family.com'], # BUGBUG: should have explicit indexes
20
+ signers: {
21
+ 0 => {name: 'Jack', email_address: 'jack@hill.com', order: 0},
22
+ 1 => {name: 'Jill', email_address: 'jill@hill.com', order: 1}
19
23
  },
20
- :file => {1 => text_file, 2 => image_file}
24
+ file: {1 => text_file, 2 => image_file}
21
25
  }
22
26
  end
23
27
 
@@ -27,18 +31,19 @@ describe HelloSign::Parameters::SignatureRequest do
27
31
  request_parameters.message = 'You must sign this.'
28
32
  request_parameters.ccs = ['lawyer@lawfirm.com', 'spouse@family.com']
29
33
  request_parameters.signers = [
30
- {:name => 'Jack', :email_address => 'jack@hill.com'},
31
- {:name => 'Jill', :email_address => 'jill@hill.com'}
34
+ {name: 'Jack', email_address: 'jack@hill.com'},
35
+ {name: 'Jill', email_address: 'jill@hill.com'}
32
36
  ]
33
37
  request_parameters.files = [
34
- {:name => 'test.txt', :io => 'text file IO object', :mime => 'text/plain'},
35
- {:name => 'test.jpg', :io => 'image file IO object', :mime => 'image/jpeg'}
38
+ @file_data_1 = {filename: 'test.txt', io: 'text file IO object', mime: 'text/plain'},
39
+ @file_data_2 = {filename: 'test.jpg', io: 'image file IO object', mime: 'image/jpeg'}
36
40
  ]
37
41
  end
38
42
 
39
43
  it "returns formatted parameters" do
40
- Faraday::UploadIO.should_receive(:new).with('text file IO object', 'text/plain', 'test.txt').and_return(text_file)
41
- Faraday::UploadIO.should_receive(:new).with('image file IO object', 'image/jpeg', 'test.jpg').and_return(image_file)
44
+ upload_io_source.should_receive(:new).with(@file_data_1).and_return(text_file)
45
+ upload_io_source.should_receive(:new).with(@file_data_2).and_return(image_file)
46
+ [text_file, image_file].each { |file| file.should_receive(:upload).and_return(file) }
42
47
 
43
48
  expect(request_parameters.formatted).to eq expected
44
49
  end
@@ -47,12 +52,12 @@ describe HelloSign::Parameters::SignatureRequest do
47
52
  context "when required parameters are omitted" do
48
53
  let(:expected) do
49
54
  {
50
- :title => nil,
51
- :subject => nil,
52
- :message => nil,
53
- :cc_email_addresses => nil,
54
- :signers => {},
55
- :file => {}
55
+ title: nil,
56
+ subject: nil,
57
+ message: nil,
58
+ cc_email_addresses: nil,
59
+ signers: {},
60
+ file: {}
56
61
  }
57
62
  end
58
63
 
@@ -4,27 +4,28 @@ require 'hello_sign/parameters/unclaimed_draft'
4
4
  require 'stringio'
5
5
 
6
6
  describe HelloSign::Parameters::UnclaimedDraft do
7
- let(:draft_parameters) { HelloSign::Parameters::UnclaimedDraft.new }
7
+ let(:upload_io_source) { double('upload IO source') }
8
+ subject(:draft_parameters) { HelloSign::Parameters::UnclaimedDraft.new }
8
9
 
9
- it "interfaces with Faraday::UploadIO properly" do
10
- draft_parameters.files = [{:name => 'test.txt', :io => StringIO.new('foobar'), :mime => 'text/plain'}]
11
- expect(draft_parameters.formatted).to be_a Hash
12
- end
10
+ before { draft_parameters.upload_io_source = upload_io_source }
13
11
 
14
12
  describe "#formatted" do
15
- let(:text_file) { double('text file') }
16
- let(:image_file) { double('image file') }
13
+ let(:text_file) { double('text file') }
14
+ let(:image) { double('image') }
17
15
 
18
16
  before do
19
17
  draft_parameters.files = [
20
- {:name => 'test.txt', :io => 'text file IO object', :mime => 'text/plain'},
21
- {:name => 'test.jpg', :io => 'image file IO object', :mime => 'image/jpeg'}
18
+ @file_data_1 = {filename: 'test.txt', io: text_file, mime: 'text/plain'},
19
+ @file_data_2 = {filename: 'test.jpg', io: image, mime: 'image/jpeg'}
22
20
  ]
23
21
  end
24
22
 
25
23
  it "returns formatted parameters" do
26
- Faraday::UploadIO.stub(:new).and_return(text_file, image_file)
27
- expect(draft_parameters.formatted).to eq({:file => {0 => text_file, 1 => image_file}})
24
+ upload_io_source.should_receive(:new).with(@file_data_1).and_return(text_file)
25
+ upload_io_source.should_receive(:new).with(@file_data_2).and_return(image)
26
+ [text_file, image].each { |file| file.should_receive(:upload).and_return(file) }
27
+
28
+ expect(draft_parameters.formatted).to eq({file: {0 => text_file, 1 => image}})
28
29
  end
29
30
  end
30
31
  end
@@ -18,20 +18,20 @@ describe HelloSign::Proxy::Account do
18
18
  it "sends a request to create an account" do
19
19
  client.should_receive(:post).with(
20
20
  '/account/create',
21
- :body => {:email_address => 'david@bowman.com', :password => 'space'},
22
- :auth_not_required => true
21
+ body: {email_address: 'david@bowman.com', password: 'space'},
22
+ auth_not_required: true
23
23
  )
24
24
  account_proxy.create(
25
- :email_address => 'david@bowman.com',
26
- :password => 'space'
25
+ email_address: 'david@bowman.com',
26
+ password: 'space'
27
27
  )
28
28
  end
29
29
 
30
30
  it "returns the API response" do
31
31
  expect(
32
32
  account_proxy.create(
33
- :email_address => 'david@bowman.com',
34
- :password => 'space'
33
+ email_address: 'david@bowman.com',
34
+ password: 'space'
35
35
  )
36
36
  ). to eq api_response
37
37
  end
@@ -6,19 +6,20 @@ describe HelloSign::Proxy::ReusableForm do
6
6
  let(:api_response) { double('API response') }
7
7
  let(:form_id) { 'form_id' }
8
8
  let(:email_address) { 'bob@example.com' }
9
- subject(:rf_proxy) { HelloSign::Proxy::ReusableForm.new(client) }
9
+ subject(:rf_proxy) { HelloSign::Proxy::ReusableForm.new(client, form_id) }
10
10
 
11
11
  before do
12
12
  client.stub(:get).and_return(api_response)
13
13
  client.stub(:post).and_return(api_response)
14
14
  end
15
15
 
16
- its(:client) { should eq client }
16
+ its(:client) { should eq client }
17
+ its(:form_id) { should eq form_id }
17
18
 
18
19
  describe "#list" do
19
20
  it "sends a request to fetch the list of reusable forms" do
20
- client.should_receive(:get).with('/reusable_form/list', :params => {:page => 10})
21
- rf_proxy.list(:page => 10)
21
+ client.should_receive(:get).with('/reusable_form/list', params: {page: 10})
22
+ rf_proxy.list(page: 10)
22
23
  end
23
24
 
24
25
  it "returns the API response" do
@@ -29,33 +30,33 @@ describe HelloSign::Proxy::ReusableForm do
29
30
  describe "#show" do
30
31
  it "sends a request to fetch the details of a reusable form" do
31
32
  client.should_receive(:get).with("/reusable_form/#{form_id}")
32
- rf_proxy.show(form_id)
33
+ rf_proxy.show
33
34
  end
34
35
 
35
36
  it "returns the API response" do
36
- expect(rf_proxy.show(form_id)).to eq api_response
37
+ expect(rf_proxy.show).to eq api_response
37
38
  end
38
39
  end
39
40
 
40
41
  describe "#grant_access" do
41
42
  it "sends a request to grant access" do
42
- client.should_receive(:post).with("/reusable_form/add_user/#{form_id}", :body => {:email_address => email_address})
43
- rf_proxy.grant_access(form_id, :email_address => email_address)
43
+ client.should_receive(:post).with("/reusable_form/add_user/#{form_id}", body: {email_address: email_address})
44
+ rf_proxy.grant_access(email_address: email_address)
44
45
  end
45
46
 
46
47
  it "returns the API response" do
47
- expect(rf_proxy.grant_access(form_id, :email => email_address)).to eq api_response
48
+ expect(rf_proxy.grant_access(:email => email_address)).to eq api_response
48
49
  end
49
50
  end
50
51
 
51
52
  describe "#revoke_access" do
52
53
  it "sends a request to revoke access" do
53
- client.should_receive(:post).with("/reusable_form/remove_user/#{form_id}", :body => {:email_address => email_address})
54
- rf_proxy.revoke_access(form_id, :email_address => email_address)
54
+ client.should_receive(:post).with("/reusable_form/remove_user/#{form_id}", body: {email_address: email_address})
55
+ rf_proxy.revoke_access(email_address: email_address)
55
56
  end
56
57
 
57
58
  it "returns the API response" do
58
- expect(rf_proxy.revoke_access(form_id, :email_address => email_address)).to eq api_response
59
+ expect(rf_proxy.revoke_access(email_address: email_address)).to eq api_response
59
60
  end
60
61
  end
61
62
  end
@@ -18,12 +18,12 @@ describe HelloSign::Proxy::Settings do
18
18
  before { client.stub(:post).and_return(api_response) }
19
19
 
20
20
  it "sends a request to update the account's settings" do
21
- client.should_receive(:post).with('/account', :body => {:callback_url => callback_url})
22
- settings.update(:callback_url => callback_url)
21
+ client.should_receive(:post).with('/account', body: {callback_url: callback_url})
22
+ settings.update(callback_url: callback_url)
23
23
  end
24
24
 
25
25
  it "returns the API response" do
26
- expect(settings.update(:callback_url => callback_url)).to be api_response
26
+ expect(settings.update(callback_url: callback_url)).to be api_response
27
27
  end
28
28
  end
29
29
  end