restforce 5.0.6 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6644bf699621fb5414dce1dce275e5a265fca50305bcfca98864b6c1683f1687
4
- data.tar.gz: 5ef0177a3a91dbe1637fc493b7f0bc478fca34c49e392abb1eccdf8bf951aa66
3
+ metadata.gz: 01b1e2a0404ca613dba1e5bf8dd0cac2672e8ae05a939693c9b06451379bc3f4
4
+ data.tar.gz: 93fc9d6f07255f56a0bc6b93fc89402f0b6f8b5b4c616f8924e02cb791d21c01
5
5
  SHA512:
6
- metadata.gz: 7c7d3e8b58743f8d4ae6ae9255c2d89cc78b06a5e963350784ff3c884396bf1ef03fb986f2aba7bd231d8ae9af2f0b2af78a77c98fcb62356ac09b1411753e13
7
- data.tar.gz: 5c8bb85fdcd28e5eba8d0939ef1868d42b99d079cddd056941ec7c4cf591d3789caa2b569cafeb8415a89755e567de1a93486dc9c18c5507275adad5631374cc
6
+ metadata.gz: 24394432042f990f2ef634a7721917fae4bc671c7b9c1a44c16e5bfc11811262ff1489418e769cb5177baacf8ad30e1f0c3fa3506b2e817c3465b324f78fd719
7
+ data.tar.gz: 5f12f8479aaab44b75a4e0c93832ed245767d5acc659f2a7d854116423e3701aa8e2203cd3ef5018e5894c504b037dee30132a4f0c09cd8b410165c6e612ebc8
data/.circleci/config.yml CHANGED
@@ -34,23 +34,23 @@ references:
34
34
  destination: test-results
35
35
 
36
36
  jobs:
37
- build-ruby271:
37
+ build-ruby30:
38
38
  docker:
39
- - image: circleci/ruby:2.7.1
39
+ - image: circleci/ruby:3.0
40
40
  steps: *steps
41
- build-ruby266:
41
+ build-ruby27:
42
42
  docker:
43
- - image: circleci/ruby:2.6.6
43
+ - image: circleci/ruby:2.7
44
44
  steps: *steps
45
- build-ruby258:
45
+ build-ruby26:
46
46
  docker:
47
- - image: circleci/ruby:2.5.8
47
+ - image: circleci/ruby:2.6
48
48
  steps: *steps
49
49
 
50
50
  workflows:
51
51
  version: 2
52
52
  tests:
53
53
  jobs:
54
- - build-ruby271
55
- - build-ruby266
56
- - build-ruby258
54
+ - build-ruby30
55
+ - build-ruby27
56
+ - build-ruby26
data/.rubocop.yml CHANGED
@@ -8,7 +8,7 @@ AllCops:
8
8
  - .*/**/*
9
9
  - vendor/**/*
10
10
  NewCops: enable
11
- TargetRubyVersion: 2.5
11
+ TargetRubyVersion: 2.6
12
12
 
13
13
  # Limit lines to 90 characters.
14
14
  Layout/LineLength:
@@ -71,4 +71,4 @@ Naming/FileName:
71
71
  - Guardfile
72
72
 
73
73
  Lint/UriEscapeUnescape:
74
- Enabled: false
74
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 5.1.0 (Aug 26, 2021)
2
+
3
+ * Add official support for Ruby 3.0 (@timrogers)
4
+ * Drop support for Ruby 2.5, which has reached end-of-life (@timrogers)
5
+ * Handle the `QUERY_TIMEOUT` error returned by Salesforce (@timrogers)
6
+ * Remove unnecessary development dependencies for the gem, which can just be in the project's `Gemfile` (@timrogers)
7
+
1
8
  ## 5.0.6 (Jun 17, 2021)
2
9
 
3
10
  * Handle the `API_DISABLED_FOR_ORG` error returned by Salesforce (@cmac)
data/Gemfile CHANGED
@@ -3,11 +3,15 @@
3
3
  source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
+ gem 'faye' unless RUBY_PLATFORM == 'java'
7
+ gem 'guard-rspec'
8
+ gem 'guard-rubocop'
6
9
  gem 'jruby-openssl', platforms: :jruby
7
- gem 'jwt'
8
10
  gem 'rake'
9
-
10
- group :development do
11
- gem 'guard-rspec'
12
- gem 'guard-rubocop'
13
- end
11
+ gem 'rspec', '~> 3.10.0'
12
+ gem 'rspec-collection_matchers', '~> 1.2.0'
13
+ gem 'rspec-its', '~> 1.3.0'
14
+ gem 'rspec_junit_formatter', '~> 0.4.1'
15
+ gem 'rubocop', '~> 1.20.0'
16
+ gem 'simplecov', '~> 0.21.2'
17
+ gem 'webmock', '~> 3.14.0'
data/README.md CHANGED
@@ -25,7 +25,7 @@ Features include:
25
25
 
26
26
  Add this line to your application's Gemfile:
27
27
 
28
- gem 'restforce', '~> 5.0.6'
28
+ gem 'restforce', '~> 5.1.0'
29
29
 
30
30
  And then execute:
31
31
 
@@ -35,8 +35,9 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install restforce
37
37
 
38
- __As of version 5.0.0, this gem is only compatible with Ruby 2.5.0 and later.__ If you're using an earlier Ruby version:
38
+ __As of version 5.0.0, this gem is only compatible with Ruby 2.6.0 and later.__ If you're using an earlier Ruby version:
39
39
 
40
+ * for Ruby 2.5, use version 5.0.6 or earlier
40
41
  * for Ruby 2.4, use version 4.3.0 or earlier
41
42
  * for Ruby 2.3, use version 3.2.0 or earlier
42
43
  * for Ruby versions 2.2, 2.1 and 2.0, use version 2.5.3 or earlier
@@ -459,7 +460,7 @@ info.user_id
459
460
 
460
461
  ### File Uploads
461
462
 
462
- Using the new [Blob Data](http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm) api feature (500mb limit):
463
+ Using the new [Blob Data](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm) api feature (500mb limit):
463
464
 
464
465
  ```ruby
465
466
  client.create('Document', FolderId: '00lE0000000FJ6H',
@@ -477,7 +478,7 @@ client.create('Document', FolderId: '00lE0000000FJ6H',
477
478
  Body: Base64::encode64(File.read('image.jpg'))
478
479
  ```
479
480
 
480
- _See also: [Inserting or updating blob data](http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm)_
481
+ _See also: [Inserting or updating blob data](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm)_
481
482
 
482
483
  * * *
483
484
 
@@ -380,7 +380,7 @@ module Restforce
380
380
  end
381
381
  else
382
382
  api_patch "sobjects/#{sobject}/#{field}/" \
383
- "#{ERB::Util.url_encode(external_id)}", attrs
383
+ "#{ERB::Util.url_encode(external_id)}", attrs
384
384
  end
385
385
 
386
386
  response.body.respond_to?(:fetch) ? response.body.fetch('id', true) : true
@@ -3,8 +3,8 @@
3
3
  module Restforce
4
4
  module ErrorCode
5
5
  GITHUB_ISSUE_URL = "https://github.com/restforce/restforce/issues/new?template=" \
6
- "unhandled-salesforce-error.md&title=Unhandled+Salesforce+error%3A+%3Cinsert+" \
7
- "error+code+here%3E"
6
+ "unhandled-salesforce-error.md&title=Unhandled+Salesforce+error" \
7
+ "%3A+%3Cinsert+error+code+here%3E"
8
8
 
9
9
  # We define all of the known errors returned by Salesforce based on the
10
10
  # documentation at
@@ -341,6 +341,8 @@ module Restforce
341
341
 
342
342
  class PrivateContactOnAsset < ResponseError; end
343
343
 
344
+ class QueryTimeout < ResponseError; end
345
+
344
346
  class RecordInUseByWorkflow < ResponseError; end
345
347
 
346
348
  class RequestLimitExceeded < ResponseError; end
@@ -573,6 +575,7 @@ module Restforce
573
575
  "PLATFORM_EVENT_PUBLISH_FAILED" => PlatformEventPublishFailed,
574
576
  "PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT" => PortalUserAlreadyExistsForContact,
575
577
  "PRIVATE_CONTACT_ON_ASSET" => PrivateContactOnAsset,
578
+ "QUERY_TIMEOUT" => QueryTimeout,
576
579
  "RECORD_IN_USE_BY_WORKFLOW" => RecordInUseByWorkflow,
577
580
  "REQUEST_LIMIT_EXCEEDED" => RequestLimitExceeded,
578
581
  "REQUEST_RUNNING_TOO_LONG" => RequestRunningTooLong,
@@ -606,9 +609,9 @@ module Restforce
606
609
  def self.get_exception_class(error_code)
607
610
  ERROR_EXCEPTION_CLASSES.fetch(error_code) do |_|
608
611
  warn "[restforce] An unrecognised error code, `#{error_code}` has been " \
609
- "received from Salesforce. Instead of raising an error-specific exception, " \
610
- "we'll raise a generic `ResponseError`. Please report this missing error code" \
611
- " on GitHub at <#{GITHUB_ISSUE_URL}>."
612
+ "received from Salesforce. Instead of raising an error-specific exception" \
613
+ ", we'll raise a generic `ResponseError`. Please report this missing " \
614
+ "error code on GitHub at <#{GITHUB_ISSUE_URL}>."
612
615
 
613
616
  # If we've received an unexpected error where we don't have a specific
614
617
  # class defined, we can return a generic ResponseError instead
@@ -618,10 +621,10 @@ module Restforce
618
621
 
619
622
  def self.const_missing(constant_name)
620
623
  warn "[restforce] You're referring to a Restforce error that isn't defined, " \
621
- "`#{name}::#{constant_name}` (for example by trying to `rescue` it). This might " \
622
- "be our fault - we've recently made some changes to how errors are defined. If " \
623
- "you're sure that this is a valid Salesforce error, then please create an " \
624
- "issue on GitHub at <#{GITHUB_ISSUE_URL}>."
624
+ "`#{name}::#{constant_name}` (for example by trying to `rescue` it). This " \
625
+ "might be our fault - we've recently made some changes to how errors are " \
626
+ "defined. If you're sure that this is a valid Salesforce error, then " \
627
+ "please create an issue on GitHub at <#{GITHUB_ISSUE_URL}>."
625
628
 
626
629
  super(constant_name)
627
630
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Restforce
4
- VERSION = '5.0.6'
4
+ VERSION = '5.1.0'
5
5
  end
data/restforce.gemspec CHANGED
@@ -22,20 +22,10 @@ Gem::Specification.new do |gem|
22
22
  'changelog_uri' => 'https://github.com/restforce/restforce/blob/master/CHANGELOG.md'
23
23
  }
24
24
 
25
- gem.required_ruby_version = '>= 2.5'
25
+ gem.required_ruby_version = '>= 2.6'
26
26
 
27
27
  gem.add_dependency 'faraday', '<= 2.0', '>= 0.9.0'
28
28
  gem.add_dependency 'faraday_middleware', ['>= 0.8.8', '<= 2.0']
29
-
30
- gem.add_dependency 'jwt', ['>= 1.5.6']
31
-
32
29
  gem.add_dependency 'hashie', '>= 1.2.0', '< 5.0'
33
-
34
- gem.add_development_dependency 'faye' unless RUBY_PLATFORM == 'java'
35
- gem.add_development_dependency 'rspec', '~> 2.14.0'
36
- gem.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
37
-
38
- gem.add_development_dependency 'rubocop', '~> 1.17.0'
39
- gem.add_development_dependency 'simplecov', '~> 0.21.2'
40
- gem.add_development_dependency 'webmock', '~> 3.13.0'
30
+ gem.add_dependency 'jwt', ['>= 1.5.6']
41
31
  end
@@ -129,18 +129,15 @@ shared_examples_for Restforce::AbstractClient do
129
129
  JSON.parse(fixture('sobject/delete_error_response'))
130
130
  end
131
131
 
132
- subject do
133
- lambda do
134
- client.update!('Account', Id: '001D000000INjVe', Name: 'Foobar')
135
- end
136
- end
132
+ it "raises Faraday::ResourceNotFound" do
133
+ expect { client.update!('Account', Id: '001D000000INjVe', Name: 'Foobar') }.
134
+ to raise_error do |exception|
135
+ expect(exception).to be_a(Faraday::ResourceNotFound)
137
136
 
138
- it {
139
- should raise_error(
140
- Faraday::ResourceNotFound,
141
- "#{error.first['errorCode']}: #{error.first['message']}"
142
- )
143
- }
137
+ expect(exception.message).
138
+ to start_with("#{error.first['errorCode']}: #{error.first['message']}")
139
+ end
140
+ end
144
141
  end
145
142
  end
146
143
 
@@ -158,7 +155,7 @@ shared_examples_for Restforce::AbstractClient do
158
155
  fixture: 'sobject/delete_error_response'
159
156
 
160
157
  subject { client.update('Account', Id: '001D000000INjVe', Name: 'Foobar') }
161
- it { should be_false }
158
+ it { should be false }
162
159
  end
163
160
 
164
161
  context 'with success' do
@@ -172,7 +169,7 @@ shared_examples_for Restforce::AbstractClient do
172
169
  client.update('Account', key => '001D000000INjVe', :Name => 'Foobar')
173
170
  end
174
171
 
175
- it { should be_true }
172
+ it { should be true }
176
173
  end
177
174
  end
178
175
  end
@@ -191,7 +188,7 @@ shared_examples_for Restforce::AbstractClient do
191
188
  Name: 'Foobar')
192
189
  end
193
190
 
194
- it { should be_true }
191
+ it { should be true }
195
192
  end
196
193
 
197
194
  context 'with string external Id key' do
@@ -200,7 +197,7 @@ shared_examples_for Restforce::AbstractClient do
200
197
  'Name' => 'Foobar')
201
198
  end
202
199
 
203
- it { should be_true }
200
+ it { should be true }
204
201
  end
205
202
  end
206
203
 
@@ -257,14 +254,14 @@ shared_examples_for Restforce::AbstractClient do
257
254
  context 'with success' do
258
255
  requests 'sobjects/Account/001D000000INjVe', method: :delete
259
256
 
260
- it { should be_true }
257
+ it { should be true }
261
258
  end
262
259
 
263
260
  context 'with a space in the id' do
264
261
  subject(:destroy!) { client.destroy!('Account', '001D000000 INjVe') }
265
262
  requests 'sobjects/Account/001D000000%20INjVe', method: :delete
266
263
 
267
- it { should be_true }
264
+ it { should be true }
268
265
  end
269
266
  end
270
267
 
@@ -277,13 +274,13 @@ shared_examples_for Restforce::AbstractClient do
277
274
  method: :delete,
278
275
  status: 404
279
276
 
280
- it { should be_false }
277
+ it { should be false }
281
278
  end
282
279
 
283
280
  context 'with success' do
284
281
  requests 'sobjects/Account/001D000000INjVe', method: :delete
285
282
 
286
- it { should be_true }
283
+ it { should be true }
287
284
  end
288
285
  end
289
286
 
@@ -368,8 +365,8 @@ shared_examples_for Restforce::AbstractClient do
368
365
  before do
369
366
  @request = stub_login_request(
370
367
  with_body: "grant_type=password&client_id=client_id" \
371
- "&client_secret=client_secret&username=foo" \
372
- "&password=barsecurity_token"
368
+ "&client_secret=client_secret&username=foo" \
369
+ "&password=barsecurity_token"
373
370
  ).to_return(status: 200, body: fixture(:auth_success_response))
374
371
  end
375
372
 
@@ -420,8 +417,8 @@ shared_examples_for Restforce::AbstractClient do
420
417
 
421
418
  @query_request = stub_login_request(
422
419
  with_body: "grant_type=password&client_id=client_id" \
423
- "&client_secret=client_secret&username=foo&" \
424
- "password=barsecurity_token"
420
+ "&client_secret=client_secret&username=foo&" \
421
+ "password=barsecurity_token"
425
422
  ).to_return(status: 200, body: fixture(:auth_success_response))
426
423
  end
427
424
 
@@ -445,7 +442,7 @@ shared_examples_for Restforce::AbstractClient do
445
442
 
446
443
  @login = stub_login_request(
447
444
  with_body: "grant_type=password&client_id=client_id&client_secret=" \
448
- "client_secret&username=foo&password=barsecurity_token"
445
+ "client_secret&username=foo&password=barsecurity_token"
449
446
  ).to_return(status: 200, body: fixture(:auth_success_response))
450
447
  end
451
448
 
@@ -98,17 +98,21 @@ shared_examples_for Restforce::Data::Client do
98
98
  end
99
99
 
100
100
  describe '.subscribe', event_machine: true do
101
+ let(:faye_double) { double('Faye') }
102
+
101
103
  context 'when given a single pushtopic' do
102
104
  it 'subscribes to the pushtopic' do
103
- client.faye.should_receive(:subscribe).with(['/topic/PushTopic'])
105
+ faye_double.should_receive(:subscribe).with(['/topic/PushTopic'])
106
+ client.stub faye: faye_double
104
107
  client.subscribe('PushTopic')
105
108
  end
106
109
  end
107
110
 
108
111
  context 'when given an array of pushtopics' do
109
112
  it 'subscribes to each pushtopic' do
110
- client.faye.should_receive(:subscribe).with(['/topic/PushTopic1',
113
+ faye_double.should_receive(:subscribe).with(['/topic/PushTopic1',
111
114
  '/topic/PushTopic2'])
115
+ client.stub faye: faye_double
112
116
  client.subscribe(%w[PushTopic1 PushTopic2])
113
117
  end
114
118
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,8 @@ Bundler.require :default, :test
8
8
  require 'faye' unless RUBY_PLATFORM == 'java'
9
9
 
10
10
  require 'webmock/rspec'
11
+ require 'rspec/collection_matchers'
12
+ require 'rspec/its'
11
13
 
12
14
  WebMock.disable_net_connect!
13
15
 
@@ -27,6 +29,14 @@ RSpec.configure do |config|
27
29
  $stderr = original_stderr
28
30
  $stdout = original_stdout
29
31
  end
32
+
33
+ config.expect_with :rspec do |expectations|
34
+ expectations.syntax = %i[expect should]
35
+ end
36
+
37
+ config.mock_with :rspec do |mocks|
38
+ mocks.syntax = %i[expect should]
39
+ end
30
40
  end
31
41
 
32
42
  # Requires supporting ruby files with custom matchers and macros, etc,
@@ -5,7 +5,7 @@ module ClientIntegrationExampleGroup
5
5
  base.class_eval do
6
6
  let(:oauth_token) do
7
7
  '00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW19ye6P' \
8
- 'E3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs'
8
+ 'E3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs'
9
9
  end
10
10
 
11
11
  let(:refresh_token) { 'refresh' }
@@ -39,13 +39,13 @@ module ClientIntegrationExampleGroup
39
39
  end
40
40
 
41
41
  RSpec.configure do |config|
42
+ describes = lambda do |described|
43
+ described <= Restforce::AbstractClient
44
+ end
45
+
42
46
  config.include self,
43
- example_group: {
44
- describes: lambda do |described|
45
- described <= Restforce::AbstractClient
46
- end,
47
- file_path: %r{spec/integration}
48
- }
47
+ file_path: %r{spec/integration},
48
+ describes: describes
49
49
 
50
50
  config.before mashify: false do
51
51
  base_options.merge!(mashify: false)
@@ -15,6 +15,6 @@ module ConcernsExampleGroup
15
15
  end
16
16
 
17
17
  RSpec.configure do |config|
18
- config.include self, example_group: { file_path: %r{spec/unit/concerns} }
18
+ config.include self, file_path: %r{spec/unit/concerns}
19
19
  end
20
20
  end
@@ -19,8 +19,7 @@ module MiddlewareExampleGroup
19
19
  end
20
20
 
21
21
  RSpec.configure do |config|
22
- config.include self,
23
- example_group: { file_path: %r{spec/unit/middleware} }
22
+ config.include self, file_path: %r{spec/unit/middleware}
24
23
  end
25
24
  end
26
25
 
@@ -13,7 +13,7 @@ describe Restforce::Collection do
13
13
 
14
14
  it { should respond_to :each }
15
15
  its(:size) { should eq 1 }
16
- its(:has_next_page?) { should be_false }
16
+ its(:has_next_page?) { should be false }
17
17
  it { should have_client client }
18
18
  its(:page_size) { should eq 1 }
19
19
 
@@ -56,7 +56,7 @@ describe Restforce::Collection do
56
56
  should(be_all { |page| expect(page).to be_a Restforce::Collection })
57
57
  end
58
58
 
59
- its(:has_next_page?) { should be_true }
59
+ its(:has_next_page?) { should be true }
60
60
  it { should(be_all { |record| expect(record).to be_a Restforce::SObject }) }
61
61
  its(:next_page) { should be_a Restforce::Collection }
62
62
  end
@@ -71,13 +71,13 @@ describe Restforce::Collection do
71
71
  context 'with size 1' do
72
72
  let(:sobject_fixture) { 'sobject/query_success_response' }
73
73
 
74
- it { should be_false }
74
+ it { should be false }
75
75
  end
76
76
 
77
77
  context 'with size 0' do
78
78
  let(:sobject_fixture) { 'sobject/query_empty_response' }
79
79
 
80
- it { should be_true }
80
+ it { should be true }
81
81
  end
82
82
  end
83
83
  end
@@ -11,7 +11,7 @@ describe Restforce::Concerns::API do
11
11
  it 'returns the user info from identity url' do
12
12
  identity_url = double('identity_url')
13
13
  response.body.stub(:identity).and_return(identity_url)
14
- client.should_receive(:api_get).with.and_return(response)
14
+ client.should_receive(:api_get).with(no_args).and_return(response)
15
15
 
16
16
  identity = double('identity')
17
17
  identity.stub(:body).and_return(identity)
@@ -268,7 +268,7 @@ describe Restforce::Concerns::API do
268
268
 
269
269
  it "delegates to :#{method}!" do
270
270
  client.should_receive(:"#{method}!").
271
- with(*args).
271
+ with(no_args).
272
272
  and_return(response)
273
273
  expect(result).to eq response
274
274
  end
@@ -276,7 +276,7 @@ describe Restforce::Concerns::API do
276
276
  it 'rescues exceptions' do
277
277
  [Faraday::ClientError].each do |exception_klass|
278
278
  client.should_receive(:"#{method}!").
279
- with(*args).
279
+ with(no_args).
280
280
  and_raise(exception_klass.new(nil))
281
281
  expect(result).to eq false
282
282
  end
@@ -314,7 +314,7 @@ describe Restforce::Concerns::API do
314
314
  it 'sends an HTTP PATCH, and returns true' do
315
315
  client.should_receive(:api_patch).
316
316
  with('sobjects/Whizbang/1234', StageName: "Call Scheduled")
317
- expect(result).to be_true
317
+ expect(result).to be true
318
318
  end
319
319
  end
320
320
 
@@ -324,7 +324,7 @@ describe Restforce::Concerns::API do
324
324
  it 'sends an HTTP PATCH, and encodes the ID' do
325
325
  client.should_receive(:api_patch).
326
326
  with('sobjects/Whizbang/1234%2F%3Fabc', StageName: "Call Scheduled")
327
- expect(result).to be_true
327
+ expect(result).to be true
328
328
  end
329
329
  end
330
330
 
@@ -348,7 +348,7 @@ describe Restforce::Concerns::API do
348
348
  client.should_receive(:api_patch).
349
349
  with('sobjects/Whizbang/External_ID__c/1234', {}).
350
350
  and_return(response)
351
- expect(result).to be_true
351
+ expect(result).to be true
352
352
  end
353
353
 
354
354
  context 'and the response body is a string' do
@@ -357,7 +357,7 @@ describe Restforce::Concerns::API do
357
357
  client.should_receive(:api_patch).
358
358
  with('sobjects/Whizbang/External_ID__c/1234', {}).
359
359
  and_return(response)
360
- expect(result).to be_true
360
+ expect(result).to be true
361
361
  end
362
362
  end
363
363
  end
@@ -431,7 +431,7 @@ describe Restforce::Concerns::API do
431
431
  client.should_receive(:api_patch).
432
432
  with('sobjects/Whizbang/External_ID__c/%E3%81%82', {}).
433
433
  and_return(response)
434
- expect(result).to be_true
434
+ expect(result).to be true
435
435
  end
436
436
  end
437
437
  end
@@ -448,7 +448,7 @@ describe Restforce::Concerns::API do
448
448
  client.should_receive(:api_patch).
449
449
  with('sobjects/Whizbang/External_ID__c/1234', {}).
450
450
  and_return(response)
451
- expect(result).to be_true
451
+ expect(result).to be true
452
452
  end
453
453
  end
454
454
  end
@@ -462,7 +462,7 @@ describe Restforce::Concerns::API do
462
462
  it 'sends and HTTP delete, and returns true' do
463
463
  client.should_receive(:api_delete).
464
464
  with('sobjects/Whizbang/1234')
465
- expect(result).to be_true
465
+ expect(result).to be true
466
466
  end
467
467
 
468
468
  context 'when the id field contains special characters' do
@@ -471,7 +471,7 @@ describe Restforce::Concerns::API do
471
471
  it 'sends an HTTP delete, and encodes the ID' do
472
472
  client.should_receive(:api_delete).
473
473
  with('sobjects/Whizbang/1234%2F%3Fabc')
474
- expect(result).to be_true
474
+ expect(result).to be true
475
475
  end
476
476
  end
477
477
  end
@@ -80,11 +80,11 @@ describe Restforce::Concerns::Authentication do
80
80
  client_secret: 'secret' }
81
81
  end
82
82
 
83
- it { should be_true }
83
+ it { should be_truthy }
84
84
  end
85
85
 
86
86
  context 'when username and password options are not provided' do
87
- it { should_not be_true }
87
+ it { should_not be_truthy }
88
88
  end
89
89
  end
90
90
 
@@ -103,11 +103,11 @@ describe Restforce::Concerns::Authentication do
103
103
  client_secret: 'secret' }
104
104
  end
105
105
 
106
- it { should be_true }
106
+ it { should be_truthy }
107
107
  end
108
108
 
109
109
  context 'when oauth options are not provided' do
110
- it { should_not be_true }
110
+ it { should_not be true }
111
111
  end
112
112
  end
113
113
 
@@ -128,11 +128,11 @@ describe Restforce::Concerns::Authentication do
128
128
  client_id: 'client' }
129
129
  end
130
130
 
131
- it { should be_true }
131
+ it { should be_truthy }
132
132
  end
133
133
 
134
134
  context 'when jwt options are not provided' do
135
- it { should_not be_true }
135
+ it { should_not be true }
136
136
  end
137
137
  end
138
138
  end
@@ -13,10 +13,10 @@ describe Restforce::Concerns::Streaming, event_machine: true do
13
13
  it 'subscribes to the topics with faye' do
14
14
  faye_double.
15
15
  should_receive(:subscribe).
16
- with(channels, &subscribe_block)
16
+ with(channels)
17
17
  client.stub faye: faye_double
18
18
 
19
- client.subscription(channels, &subscribe_block)
19
+ client.subscription(channels)
20
20
  end
21
21
 
22
22
  context "replay_handlers" do
@@ -110,7 +110,7 @@ describe Restforce::Concerns::Streaming, event_machine: true do
110
110
  end
111
111
  end
112
112
 
113
- describe Restforce::Concerns::Streaming::ReplayExtension do
113
+ describe "ReplayExtension" do
114
114
  let(:handlers) { {} }
115
115
  let(:extension) { Restforce::Concerns::Streaming::ReplayExtension.new(handlers) }
116
116
 
@@ -76,7 +76,7 @@ describe Restforce do
76
76
  subject { Restforce.log? }
77
77
 
78
78
  context 'by default' do
79
- it { should be_false }
79
+ it { should be false }
80
80
  end
81
81
  end
82
82
 
@@ -17,14 +17,14 @@ describe Restforce::Middleware::Authentication::JWTBearer do
17
17
  let(:success_request) do
18
18
  stub_login_request(
19
19
  body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
20
- "assertion=abc1234567890"
20
+ "assertion=abc1234567890"
21
21
  ).to_return(status: 200, body: fixture(:auth_success_response))
22
22
  end
23
23
 
24
24
  let(:fail_request) do
25
25
  stub_login_request(
26
26
  body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
27
- "assertion=abc1234567890"
27
+ "assertion=abc1234567890"
28
28
  ).to_return(status: 400, body: fixture(:refresh_error_response))
29
29
  end
30
30
  end
@@ -47,14 +47,14 @@ describe Restforce::Middleware::Authentication::JWTBearer do
47
47
  let(:success_request) do
48
48
  stub_login_request(
49
49
  body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
50
- "assertion=abc1234567890"
50
+ "assertion=abc1234567890"
51
51
  ).to_return(status: 200, body: fixture(:auth_success_response))
52
52
  end
53
53
 
54
54
  let(:fail_request) do
55
55
  stub_login_request(
56
56
  body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
57
- "assertion=abc1234567890"
57
+ "assertion=abc1234567890"
58
58
  ).to_return(status: 400, body: fixture(:refresh_error_response))
59
59
  end
60
60
  end
@@ -17,14 +17,14 @@ describe Restforce::Middleware::Authentication::Password do
17
17
  let(:success_request) do
18
18
  stub_login_request(
19
19
  body: "grant_type=password&client_id=client_id&client_secret=client_secret" \
20
- "&username=foo&password=barsecurity_token"
20
+ "&username=foo&password=barsecurity_token"
21
21
  ).to_return(status: 200, body: fixture(:auth_success_response))
22
22
  end
23
23
 
24
24
  let(:fail_request) do
25
25
  stub_login_request(
26
26
  body: "grant_type=password&client_id=client_id&client_secret=client_secret" \
27
- "&username=foo&password=barsecurity_token"
27
+ "&username=foo&password=barsecurity_token"
28
28
  ).to_return(status: 400, body: fixture(:auth_error_response))
29
29
  end
30
30
  end
@@ -15,14 +15,14 @@ describe Restforce::Middleware::Authentication::Token do
15
15
  let(:success_request) do
16
16
  stub_login_request(
17
17
  body: "grant_type=refresh_token&refresh_token=refresh_token&" \
18
- "client_id=client_id&client_secret=client_secret"
18
+ "client_id=client_id&client_secret=client_secret"
19
19
  ).to_return(status: 200, body: fixture(:auth_success_response))
20
20
  end
21
21
 
22
22
  let(:fail_request) do
23
23
  stub_login_request(
24
24
  body: "grant_type=refresh_token&refresh_token=refresh_token&" \
25
- "client_id=client_id&client_secret=client_secret"
25
+ "client_id=client_id&client_secret=client_secret"
26
26
  ).to_return(status: 400, body: fixture(:refresh_error_response))
27
27
  end
28
28
  end
@@ -58,11 +58,11 @@ describe Restforce::Middleware::Gzip do
58
58
  env[:response_headers]['Content-Encoding'] = 'gzip'
59
59
  end
60
60
 
61
- it { should be_true }
61
+ it { should be true }
62
62
  end
63
63
 
64
64
  context 'when not gzipped' do
65
- it { should be_false }
65
+ it { should be false }
66
66
  end
67
67
  end
68
68
  end
@@ -14,8 +14,10 @@ describe Restforce::Middleware::RaiseError do
14
14
  let(:status) { 404 }
15
15
 
16
16
  it 'raises Restforce::NotFoundError' do
17
- expect { on_complete }.to raise_error Restforce::NotFoundError,
18
- 'INVALID_FIELD: error_message'
17
+ expect { on_complete }.to raise_error do |error|
18
+ expect(error).to be_a Restforce::NotFoundError
19
+ expect(error.message).to start_with("INVALID_FIELD: error_message")
20
+ end
19
21
  end
20
22
 
21
23
  it 'raises an error that inherits from Faraday::ResourceNotFound' do
@@ -40,8 +42,10 @@ describe Restforce::Middleware::RaiseError do
40
42
  let(:status) { 400 }
41
43
 
42
44
  it "raises an error derived from the response's errorCode" do
43
- expect { on_complete }.to raise_error Restforce::ErrorCode::InvalidField,
44
- 'INVALID_FIELD: error_message'
45
+ expect { on_complete }.to raise_error do |error|
46
+ expect(error).to be_a Restforce::ErrorCode::InvalidField
47
+ expect(error.message).to start_with("INVALID_FIELD: error_message")
48
+ end
45
49
  end
46
50
 
47
51
  it 'raises an error that inherits from Faraday::ClientError' do
@@ -53,8 +57,10 @@ describe Restforce::Middleware::RaiseError do
53
57
  let(:status) { 401 }
54
58
 
55
59
  it 'raises Restforce::UnauthorizedError' do
56
- expect { on_complete }.to raise_error Restforce::UnauthorizedError,
57
- 'INVALID_FIELD: error_message'
60
+ expect { on_complete }.to raise_error do |error|
61
+ expect(error).to be_a Restforce::UnauthorizedError
62
+ expect(error.message).to start_with("INVALID_FIELD: error_message")
63
+ end
58
64
  end
59
65
  end
60
66
 
@@ -76,13 +82,17 @@ describe Restforce::Middleware::RaiseError do
76
82
  let(:status) { 400 }
77
83
 
78
84
  it 'raises a generic Restforce::ResponseError' do
79
- expect { on_complete }.to raise_error Restforce::ResponseError,
80
- "(error code missing): #{body}"
85
+ expect { on_complete }.to raise_error do |error|
86
+ expect(error).to be_a Restforce::ResponseError
87
+ expect(error.message).to start_with("(error code missing): An error occured")
88
+ end
81
89
  end
82
90
 
83
91
  it 'raises an error that inherits from Faraday::ClientError' do
84
- expect { on_complete }.to raise_error Faraday::ClientError,
85
- "(error code missing): #{body}"
92
+ expect { on_complete }.to raise_error do |error|
93
+ expect(error).to be_a Faraday::ClientError
94
+ expect(error.message).to start_with("(error code missing): An error occured")
95
+ end
86
96
  end
87
97
  end
88
98
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.6
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Rogers
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-17 00:00:00.000000000 Z
12
+ date: 2021-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -51,20 +51,6 @@ dependencies:
51
51
  - - "<="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.0'
54
- - !ruby/object:Gem::Dependency
55
- name: jwt
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 1.5.6
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 1.5.6
68
54
  - !ruby/object:Gem::Dependency
69
55
  name: hashie
70
56
  requirement: !ruby/object:Gem::Requirement
@@ -86,89 +72,19 @@ dependencies:
86
72
  - !ruby/object:Gem::Version
87
73
  version: '5.0'
88
74
  - !ruby/object:Gem::Dependency
89
- name: faye
75
+ name: jwt
90
76
  requirement: !ruby/object:Gem::Requirement
91
77
  requirements:
92
78
  - - ">="
93
79
  - !ruby/object:Gem::Version
94
- version: '0'
95
- type: :development
80
+ version: 1.5.6
81
+ type: :runtime
96
82
  prerelease: false
97
83
  version_requirements: !ruby/object:Gem::Requirement
98
84
  requirements:
99
85
  - - ">="
100
86
  - !ruby/object:Gem::Version
101
- version: '0'
102
- - !ruby/object:Gem::Dependency
103
- name: rspec
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: 2.14.0
109
- type: :development
110
- prerelease: false
111
- version_requirements: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: 2.14.0
116
- - !ruby/object:Gem::Dependency
117
- name: rspec_junit_formatter
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: 0.4.1
123
- type: :development
124
- prerelease: false
125
- version_requirements: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: 0.4.1
130
- - !ruby/object:Gem::Dependency
131
- name: rubocop
132
- requirement: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: 1.17.0
137
- type: :development
138
- prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: 1.17.0
144
- - !ruby/object:Gem::Dependency
145
- name: simplecov
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: 0.21.2
151
- type: :development
152
- prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: 0.21.2
158
- - !ruby/object:Gem::Dependency
159
- name: webmock
160
- requirement: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: 3.13.0
165
- type: :development
166
- prerelease: false
167
- version_requirements: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - "~>"
170
- - !ruby/object:Gem::Version
171
- version: 3.13.0
87
+ version: 1.5.6
172
88
  description: A lightweight Ruby client for the Salesforce REST API
173
89
  email:
174
90
  - me@timrogers.co.uk
@@ -328,14 +244,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
328
244
  requirements:
329
245
  - - ">="
330
246
  - !ruby/object:Gem::Version
331
- version: '2.5'
247
+ version: '2.6'
332
248
  required_rubygems_version: !ruby/object:Gem::Requirement
333
249
  requirements:
334
250
  - - ">="
335
251
  - !ruby/object:Gem::Version
336
252
  version: '0'
337
253
  requirements: []
338
- rubygems_version: 3.2.5
254
+ rubygems_version: 3.1.6
339
255
  signing_key:
340
256
  specification_version: 4
341
257
  summary: A lightweight Ruby client for the Salesforce REST API