restforce 1.5.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of restforce might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +60 -0
  3. data/.rubocop_todo.yml +117 -0
  4. data/.travis.yml +3 -5
  5. data/CHANGELOG.md +6 -0
  6. data/README.md +2 -0
  7. data/Rakefile +1 -1
  8. data/lib/restforce/abstract_client.rb +1 -1
  9. data/lib/restforce/attachment.rb +1 -3
  10. data/lib/restforce/concerns/api.rb +22 -17
  11. data/lib/restforce/concerns/authentication.rb +4 -3
  12. data/lib/restforce/concerns/base.rb +42 -31
  13. data/lib/restforce/concerns/caching.rb +1 -3
  14. data/lib/restforce/concerns/canvas.rb +0 -2
  15. data/lib/restforce/concerns/connection.rb +18 -12
  16. data/lib/restforce/concerns/picklists.rb +10 -10
  17. data/lib/restforce/concerns/streaming.rb +9 -4
  18. data/lib/restforce/concerns/verbs.rb +0 -2
  19. data/lib/restforce/config.rb +19 -13
  20. data/lib/restforce/data/client.rb +8 -1
  21. data/lib/restforce/mash.rb +6 -10
  22. data/lib/restforce/middleware.rb +3 -1
  23. data/lib/restforce/middleware/authentication.rb +21 -7
  24. data/lib/restforce/middleware/authentication/password.rb +5 -9
  25. data/lib/restforce/middleware/authentication/token.rb +4 -8
  26. data/lib/restforce/middleware/authorization.rb +0 -3
  27. data/lib/restforce/middleware/caching.rb +4 -4
  28. data/lib/restforce/middleware/instance_url.rb +3 -5
  29. data/lib/restforce/middleware/logger.rb +7 -7
  30. data/lib/restforce/middleware/mashify.rb +2 -3
  31. data/lib/restforce/middleware/multipart.rb +15 -8
  32. data/lib/restforce/middleware/raise_error.rb +2 -1
  33. data/lib/restforce/patches/parts.rb +2 -3
  34. data/lib/restforce/signed_request.rb +2 -2
  35. data/lib/restforce/sobject.rb +1 -3
  36. data/lib/restforce/tooling/client.rb +1 -3
  37. data/lib/restforce/upload_io.rb +1 -3
  38. data/lib/restforce/version.rb +1 -1
  39. data/restforce.gemspec +7 -4
  40. data/spec/integration/abstract_client_spec.rb +123 -75
  41. data/spec/integration/data/client_spec.rb +24 -12
  42. data/spec/spec_helper.rb +2 -2
  43. data/spec/support/client_integration.rb +23 -17
  44. data/spec/support/concerns.rb +2 -2
  45. data/spec/support/event_machine.rb +3 -3
  46. data/spec/support/fixture_helpers.rb +16 -12
  47. data/spec/support/middleware.rb +16 -8
  48. data/spec/unit/abstract_client_spec.rb +1 -1
  49. data/spec/unit/attachment_spec.rb +2 -1
  50. data/spec/unit/collection_spec.rb +13 -4
  51. data/spec/unit/concerns/api_spec.rb +15 -13
  52. data/spec/unit/concerns/authentication_spec.rb +20 -17
  53. data/spec/unit/concerns/base_spec.rb +2 -2
  54. data/spec/unit/concerns/caching_spec.rb +2 -2
  55. data/spec/unit/concerns/canvas_spec.rb +3 -3
  56. data/spec/unit/concerns/connection_spec.rb +6 -7
  57. data/spec/unit/concerns/streaming_spec.rb +8 -8
  58. data/spec/unit/config_spec.rb +6 -6
  59. data/spec/unit/data/client_spec.rb +1 -1
  60. data/spec/unit/mash_spec.rb +1 -1
  61. data/spec/unit/middleware/authentication/password_spec.rb +14 -12
  62. data/spec/unit/middleware/authentication/token_spec.rb +12 -10
  63. data/spec/unit/middleware/authentication_spec.rb +15 -11
  64. data/spec/unit/middleware/authorization_spec.rb +1 -1
  65. data/spec/unit/middleware/gzip_spec.rb +1 -1
  66. data/spec/unit/middleware/instance_url_spec.rb +2 -2
  67. data/spec/unit/middleware/mashify_spec.rb +2 -2
  68. data/spec/unit/middleware/raise_error_spec.rb +23 -7
  69. data/spec/unit/sobject_spec.rb +16 -9
  70. data/spec/unit/tooling/client_spec.rb +1 -1
  71. metadata +23 -5
@@ -6,7 +6,7 @@ describe Restforce::Middleware::InstanceURL do
6
6
 
7
7
  context 'when the instance url is not set' do
8
8
  before do
9
- client.stub_chain :connection, :url_prefix => URI.parse('http:/')
9
+ client.stub_chain :connection, url_prefix: URI.parse('http:/')
10
10
  end
11
11
 
12
12
  it { should raise_error Restforce::UnauthorizedError }
@@ -14,7 +14,7 @@ describe Restforce::Middleware::InstanceURL do
14
14
 
15
15
  context 'when the instance url is set' do
16
16
  before do
17
- client.stub_chain :connection, :url_prefix => URI.parse('http://foobar.com/')
17
+ client.stub_chain :connection, url_prefix: URI.parse('http://foobar.com/')
18
18
  app.should_receive(:call).once
19
19
  end
20
20
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Restforce::Middleware::Mashify do
4
- let(:env) { { :body => JSON.parse(fixture('sobject/query_success_response')) } }
4
+ let(:env) { { body: JSON.parse(fixture('sobject/query_success_response')) } }
5
5
  subject(:middleware) {
6
6
  described_class.new(lambda {|env|
7
7
  Faraday::Response.new(env)
@@ -10,7 +10,7 @@ describe Restforce::Middleware::Mashify do
10
10
 
11
11
  describe '.call' do
12
12
  it "should change the body to a Restforce::Collection" do
13
- expect( middleware.call(env).body ).to be_kind_of(Restforce::Collection)
13
+ expect(middleware.call(env).body).to be_kind_of(Restforce::Collection)
14
14
  end
15
15
  end
16
16
  end
@@ -2,31 +2,47 @@ require 'spec_helper'
2
2
 
3
3
  describe Restforce::Middleware::RaiseError do
4
4
  let(:body) { fixture('sobject/query_error_response') }
5
- let(:env) { { :status => status, :body => body } }
5
+ let(:env) { { status: status, body: body } }
6
6
  let(:middleware) { described_class.new app }
7
7
 
8
8
  describe '.on_complete' do
9
- subject { lambda { middleware.on_complete(env) } }
9
+ subject(:on_complete) { middleware.on_complete(env) }
10
10
 
11
11
  context 'when the status code is 404' do
12
12
  let(:status) { 404 }
13
- it { should raise_error Faraday::Error::ResourceNotFound, 'INVALID_FIELD: error_message' }
13
+
14
+ it "raises an error" do
15
+ expect { on_complete }.to raise_error Faraday::Error::ResourceNotFound,
16
+ 'INVALID_FIELD: error_message'
17
+ end
14
18
  end
15
19
 
16
20
  context 'when the status code is 400' do
17
21
  let(:status) { 400 }
18
- it { should raise_error Faraday::Error::ClientError, 'INVALID_FIELD: error_message' }
22
+
23
+ it "raises an error" do
24
+ expect { on_complete }.to raise_error Faraday::Error::ClientError,
25
+ 'INVALID_FIELD: error_message'
26
+ end
19
27
  end
20
28
 
21
29
  context 'when the status code is 401' do
22
30
  let(:status) { 401 }
23
- it { should raise_error Restforce::UnauthorizedError, 'INVALID_FIELD: error_message' }
31
+
32
+ it "raises an error" do
33
+ expect { on_complete }.to raise_error Restforce::UnauthorizedError,
34
+ 'INVALID_FIELD: error_message'
35
+ end
24
36
  end
25
37
 
26
38
  context 'when the status code is 413' do
27
39
  let(:status) { 413 }
28
- let(:body) { '' } #Zero length response
29
- it { should raise_error Faraday::Error::ClientError, 'HTTP 413 - Request Entity Too Large' }
40
+ let(:body) { '' } # Zero length response
41
+
42
+ it "raises an error" do
43
+ expect { on_complete }.to raise_error Faraday::Error::ClientError,
44
+ 'HTTP 413 - Request Entity Too Large'
45
+ end
30
46
  end
31
47
  end
32
48
  end
@@ -1,8 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Restforce::SObject do
4
- let(:client) { double('Client') }
5
- let(:hash) { JSON.parse(fixture('sobject/query_success_response'))['records'].first }
4
+ let(:client) { double('Client') }
5
+
6
+ let(:hash) do
7
+ JSON.parse(fixture('sobject/query_success_response'))['records'].first
8
+ end
9
+
6
10
  subject(:sobject) { described_class.new(hash, client) }
7
11
 
8
12
  describe '#new' do
@@ -34,20 +38,23 @@ describe Restforce::SObject do
34
38
  end
35
39
  end
36
40
 
37
- { :save => :update,
38
- :save! => :update!,
39
- :destroy => :destroy,
40
- :destroy! => :destroy! }.each do |method, receiver|
41
+ { save: :update,
42
+ save!: :update!,
43
+ destroy: :destroy,
44
+ destroy!: :destroy! }.each do |method, receiver|
41
45
  describe ".#{method}" do
42
- subject { lambda { sobject.send(method) } }
46
+ subject(:send_method) { sobject.send(method) }
43
47
 
44
48
  context 'when an Id was not queried' do
45
- it { should raise_error ArgumentError, 'You need to query the Id for the record first.' }
49
+ it "raises an error" do
50
+ expect { send_method }.to raise_error ArgumentError,
51
+ /need to query the Id for the record/
52
+ end
46
53
  end
47
54
 
48
55
  context 'when an Id is present' do
49
56
  before do
50
- hash.merge!(:Id => '001D000000INjVe')
57
+ hash.merge!(Id: '001D000000INjVe')
51
58
  client.should_receive(receiver)
52
59
  end
53
60
 
@@ -4,4 +4,4 @@ describe Restforce::Tooling::Client do
4
4
  subject { described_class }
5
5
 
6
6
  it { should < Restforce::AbstractClient }
7
- end
7
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric J. Holmes
8
+ - Tim Rogers
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-06-26 00:00:00.000000000 Z
12
+ date: 2015-06-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: faraday
@@ -120,6 +121,20 @@ dependencies:
120
121
  - - "~>"
121
122
  - !ruby/object:Gem::Version
122
123
  version: 0.7.1
124
+ - !ruby/object:Gem::Dependency
125
+ name: rubocop
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.31.0
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.31.0
123
138
  - !ruby/object:Gem::Dependency
124
139
  name: faye
125
140
  requirement: !ruby/object:Gem::Requirement
@@ -134,14 +149,17 @@ dependencies:
134
149
  - - ">="
135
150
  - !ruby/object:Gem::Version
136
151
  version: '0'
137
- description: A lightweight ruby client for the Salesforce REST api.
152
+ description: A lightweight ruby client for the Salesforce REST API.
138
153
  email:
139
154
  - eric@ejholmes.net
155
+ - tim@gocardless.com
140
156
  executables: []
141
157
  extensions: []
142
158
  extra_rdoc_files: []
143
159
  files:
144
160
  - ".gitignore"
161
+ - ".rubocop.yml"
162
+ - ".rubocop_todo.yml"
145
163
  - ".travis.yml"
146
164
  - CHANGELOG.md
147
165
  - Gemfile
@@ -264,7 +282,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
264
282
  requirements:
265
283
  - - ">="
266
284
  - !ruby/object:Gem::Version
267
- version: '0'
285
+ version: 1.9.3
268
286
  required_rubygems_version: !ruby/object:Gem::Requirement
269
287
  requirements:
270
288
  - - ">="
@@ -275,7 +293,7 @@ rubyforge_project:
275
293
  rubygems_version: 2.4.7
276
294
  signing_key:
277
295
  specification_version: 4
278
- summary: A lightweight ruby client for the Salesforce REST api.
296
+ summary: A lightweight ruby client for the Salesforce REST API.
279
297
  test_files:
280
298
  - spec/fixtures/auth_error_response.json
281
299
  - spec/fixtures/auth_success_response.json