percy-client 1.13.5 → 1.13.6

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
  SHA1:
3
- metadata.gz: 2e0d958dccb6268ab3679e448bf45263d1fac005
4
- data.tar.gz: 2ae421a83b94e20b1bf7c32e2b0e2e980eb1e4e2
3
+ metadata.gz: dd84cf9ac38282cc0057f714197b65e0e75a8122
4
+ data.tar.gz: 01f640d98197a7e4a34b0f09b33d31e8e05e7900
5
5
  SHA512:
6
- metadata.gz: 0918a1918c049d77188323d387f33bbd83a4aa6ed0e947911564732034849e97581e62404f516962ab97a88f3095792ae4fb3683cdd5dad761b0c76d21abb7eb
7
- data.tar.gz: 7967e3894498c7d3ee5d2008d011a377369f938bffc936cd856b3025d9a26315dfabfa95a59f8317f5286db7c1d469ea5b24b440cc3bfe5c8d7973aac392d2a2
6
+ metadata.gz: 015eec97ba845a645d0a9e3f309bc4542746bc101970ae5506a6c40df5444d7948393166361a4206e33683584cc0b57d97c9a50cb5e323dc408f5b3a781e14c3
7
+ data.tar.gz: 5513c0a98c57e71cb980f33373d2f0aa447bd4bbdd680cebc6af1ead78c01b9af58415429d3a6f3658a006a187a7a0d4d2263a8eac1a56179671bda28a432da3
data/lib/percy/client.rb CHANGED
@@ -32,18 +32,38 @@ module Percy
32
32
  end
33
33
  end
34
34
 
35
- class ClientError < HttpError; end # 4xx;
36
- class BadRequestError < ClientError; end # 400.
37
- class UnauthorizedError < ClientError; end # 401.
38
- class PaymentRequiredError < ClientError; end # 402.
39
- class ForbiddenError < ClientError; end # 403.
40
- class NotFoundError < ClientError; end # 404.
41
- class ConflictError < ClientError; end # 409.
42
-
43
- class ServerError < HttpError; end # 5xx.
44
- class InternalServerError < ServerError; end # 500.
45
- class BadGatewayError < ServerError; end # 502.
46
- class ServiceUnavailableError < ServerError; end # 503.
35
+ # 4xx
36
+ class ClientError < HttpError; end
37
+
38
+ # 400
39
+ class BadRequestError < ClientError; end
40
+
41
+ # 401
42
+ class UnauthorizedError < ClientError; end
43
+
44
+ # 402
45
+ class PaymentRequiredError < ClientError; end
46
+
47
+ # 403
48
+ class ForbiddenError < ClientError; end
49
+
50
+ # 404
51
+ class NotFoundError < ClientError; end
52
+
53
+ # 409
54
+ class ConflictError < ClientError; end
55
+
56
+ # 5xx
57
+ class ServerError < HttpError; end
58
+
59
+ # 500
60
+ class InternalServerError < ServerError; end
61
+
62
+ # 502
63
+ class BadGatewayError < ServerError; end
64
+
65
+ # 503
66
+ class ServiceUnavailableError < ServerError; end
47
67
 
48
68
  attr_reader :config, :client_info, :environment_info
49
69
 
@@ -91,6 +91,9 @@ module Percy
91
91
  request.body = data.to_json
92
92
  end
93
93
  rescue Faraday::TimeoutError
94
+ if (retries -= 1) >= 0
95
+ retry
96
+ end
94
97
  raise Percy::Client::TimeoutError
95
98
  rescue Faraday::ConnectionFailed
96
99
  raise Percy::Client::ConnectionFailed
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  class Client
3
- VERSION = '1.13.5'.freeze
3
+ VERSION = '1.13.6'.freeze
4
4
  end
5
5
  end
@@ -39,6 +39,7 @@ RSpec.describe Percy::Client::Builds, :vcr do
39
39
  expect(build['data']['relationships']['missing-resources']).to be
40
40
  expect(build['data']['relationships']['missing-resources']['data']).to_not be
41
41
  end
42
+
42
43
  it 'accepts optional resources' do
43
44
  resources = []
44
45
  resources << Percy::Client::Resource.new('/css/test.css', sha: sha)
@@ -64,6 +65,7 @@ RSpec.describe Percy::Client::Builds, :vcr do
64
65
  ENV['PERCY_PARALLEL_NONCE'] = 'nonce'
65
66
  ENV['PERCY_PARALLEL_TOTAL'] = '4'
66
67
  end
68
+
67
69
  after(:each) do
68
70
  ENV['PERCY_BRANCH'] = nil
69
71
  ENV['PERCY_TARGET_BRANCH'] = nil
@@ -71,6 +73,7 @@ RSpec.describe Percy::Client::Builds, :vcr do
71
73
  ENV['PERCY_PARALLEL_NONCE'] = nil
72
74
  ENV['PERCY_PARALLEL_TOTAL'] = nil
73
75
  end
76
+
74
77
  it 'passes through some attributes from environment' do
75
78
  # Whitebox test to check POST data.
76
79
  expect_any_instance_of(Percy::Client).to \
@@ -99,7 +102,8 @@ RSpec.describe Percy::Client::Builds, :vcr do
99
102
  Percy.create_build('fotinakis/percy-examples')
100
103
  end
101
104
  end
102
- context 'parallel test environment' do
105
+
106
+ context 'when in a parallel test environment' do
103
107
  it 'passes through parallelism variables' do
104
108
  build = Percy.create_build(
105
109
  'fotinakis/percy-examples',
@@ -111,6 +115,7 @@ RSpec.describe Percy::Client::Builds, :vcr do
111
115
  end
112
116
  end
113
117
  end
118
+
114
119
  describe '#finalize_build' do
115
120
  it 'finalizes a build' do
116
121
  build = Percy.create_build('fotinakis/percy-examples')
@@ -94,6 +94,15 @@ RSpec.describe Percy::Client::Connection do
94
94
  expect { response }.to raise_error(Percy::Client::ConnectionFailed)
95
95
  end
96
96
 
97
+ context 'with retries enabled' do
98
+ subject(:response) { Percy.client.post(uri, {}, retries: 3) }
99
+
100
+ it 'raises an exception on retry exhaustion' do
101
+ stub_request(:post, uri).to_raise(Faraday::TimeoutError)
102
+ expect { response }.to raise_error(Percy::Client::TimeoutError)
103
+ end
104
+ end
105
+
97
106
  shared_examples_for 'HTTP status raises custom error class' do |http_status, error_class|
98
107
  subject(:request) { Percy.client.post(uri, {}, retries: 0) }
99
108
 
@@ -103,7 +103,7 @@ RSpec.describe Percy::Client::Environment do
103
103
  ENV['TRAVIS_REPO_SLUG'] = @original_env['TRAVIS_REPO_SLUG']
104
104
  end
105
105
 
106
- context 'no known CI environment' do
106
+ context 'with no known CI environment' do
107
107
  describe '#current_ci' do
108
108
  it 'is nil' do
109
109
  expect(Percy::Client::Environment.current_ci).to be_nil
@@ -243,7 +243,7 @@ RSpec.describe Percy::Client::Environment do
243
243
  end
244
244
  end
245
245
 
246
- context 'in Jenkins CI' do
246
+ context 'when in Jenkins CI' do
247
247
  before(:each) do
248
248
  ENV['JENKINS_URL'] = 'http://localhost:8080/'
249
249
  ENV['BUILD_NUMBER'] = '111'
@@ -263,7 +263,7 @@ RSpec.describe Percy::Client::Environment do
263
263
  end
264
264
  end
265
265
 
266
- context 'in Travis CI' do
266
+ context 'when in Travis CI' do
267
267
  before(:each) do
268
268
  ENV['TRAVIS_BUILD_ID'] = '1234'
269
269
  ENV['TRAVIS_BUILD_NUMBER'] = 'build-number'
@@ -286,7 +286,7 @@ RSpec.describe Percy::Client::Environment do
286
286
  expect(Percy::Client::Environment.parallel_total_shards).to be_nil
287
287
  end
288
288
 
289
- context 'Pull Request build' do
289
+ context ' with a pull request build' do
290
290
  before(:each) do
291
291
  ENV['TRAVIS_PULL_REQUEST'] = '256'
292
292
  ENV['TRAVIS_PULL_REQUEST_BRANCH'] = 'travis-pr-branch'
@@ -300,7 +300,7 @@ RSpec.describe Percy::Client::Environment do
300
300
  end
301
301
  end
302
302
 
303
- context 'parallel build' do
303
+ context 'with parallel build' do
304
304
  before(:each) do
305
305
  ENV['CI_NODE_TOTAL'] = '3'
306
306
  end
@@ -312,7 +312,7 @@ RSpec.describe Percy::Client::Environment do
312
312
  end
313
313
  end
314
314
 
315
- context 'in Circle CI' do
315
+ context 'when in Circle CI' do
316
316
  before(:each) do
317
317
  ENV['CIRCLECI'] = 'true'
318
318
  ENV['CIRCLE_BRANCH'] = 'circle-branch'
@@ -334,7 +334,7 @@ RSpec.describe Percy::Client::Environment do
334
334
  expect(Percy::Client::Environment.parallel_total_shards).to be_nil
335
335
  end
336
336
 
337
- context 'parallel build' do
337
+ context 'with a parallel build' do
338
338
  before(:each) do
339
339
  ENV['CIRCLE_NODE_TOTAL'] = '3'
340
340
  end
@@ -346,7 +346,7 @@ RSpec.describe Percy::Client::Environment do
346
346
  end
347
347
  end
348
348
 
349
- context 'in Codeship' do
349
+ context 'when in Codeship' do
350
350
  before(:each) do
351
351
  ENV['CI_NAME'] = 'codeship'
352
352
  ENV['CI_BRANCH'] = 'codeship-branch'
@@ -366,7 +366,7 @@ RSpec.describe Percy::Client::Environment do
366
366
  expect(Percy::Client::Environment.parallel_total_shards).to be_nil
367
367
  end
368
368
 
369
- context 'parallel build' do
369
+ context 'with a parallel build' do
370
370
  before(:each) do
371
371
  ENV['CI_NODE_TOTAL'] = '3'
372
372
  end
@@ -378,7 +378,7 @@ RSpec.describe Percy::Client::Environment do
378
378
  end
379
379
  end
380
380
 
381
- context 'in Drone' do
381
+ context 'when in Drone' do
382
382
  before(:each) do
383
383
  ENV['DRONE'] = 'true'
384
384
  ENV['DRONE_COMMIT'] = 'drone-commit-sha'
@@ -395,7 +395,7 @@ RSpec.describe Percy::Client::Environment do
395
395
  end
396
396
  end
397
397
 
398
- context 'in Semaphore CI' do
398
+ context 'when in Semaphore CI' do
399
399
  before(:each) do
400
400
  ENV['SEMAPHORE'] = 'true'
401
401
  ENV['BRANCH_NAME'] = 'semaphore-branch'
@@ -418,7 +418,7 @@ RSpec.describe Percy::Client::Environment do
418
418
  expect(Percy::Client::Environment.parallel_total_shards).to be_nil
419
419
  end
420
420
 
421
- context 'parallel build' do
421
+ context 'with a parallel build' do
422
422
  before(:each) do
423
423
  ENV['SEMAPHORE_THREAD_COUNT'] = '3'
424
424
  end
@@ -431,7 +431,7 @@ RSpec.describe Percy::Client::Environment do
431
431
  end
432
432
  end
433
433
 
434
- context 'in Buildkite' do
434
+ context 'when in Buildkite' do
435
435
  before(:each) do
436
436
  ENV['BUILDKITE'] = 'true'
437
437
  ENV['BUILDKITE_COMMIT'] = 'buildkite-commit-sha'
@@ -450,7 +450,8 @@ RSpec.describe Percy::Client::Environment do
450
450
  expect(Percy::Client::Environment.parallel_nonce).to eq('buildkite-build-id')
451
451
  expect(Percy::Client::Environment.parallel_total_shards).to be_nil
452
452
  end
453
- context 'Parallel Build' do
453
+
454
+ context 'when running a parallel build' do
454
455
  before(:each) do
455
456
  ENV['BUILDKITE_PARALLEL_JOB_COUNT'] = '3'
456
457
  end
@@ -459,7 +460,8 @@ RSpec.describe Percy::Client::Environment do
459
460
  expect(Percy::Client::Environment.parallel_total_shards).to eq(3)
460
461
  end
461
462
  end
462
- context 'Pull Request build' do
463
+
464
+ context 'with a pull request build' do
463
465
  before(:each) do
464
466
  ENV['BUILDKITE_PULL_REQUEST'] = '123'
465
467
  end
@@ -467,7 +469,8 @@ RSpec.describe Percy::Client::Environment do
467
469
  expect(Percy::Client::Environment.pull_request_number).to eq('123')
468
470
  end
469
471
  end
470
- context 'UI-triggered HEAD build' do
472
+
473
+ context 'with a UI-triggered HEAD build' do
471
474
  before(:each) do
472
475
  ENV['BUILDKITE_COMMIT'] = 'HEAD'
473
476
  end
@@ -476,7 +479,8 @@ RSpec.describe Percy::Client::Environment do
476
479
  end
477
480
  end
478
481
  end
479
- context 'in Gitlab CI' do
482
+
483
+ context 'when in Gitlab CI' do
480
484
  before(:each) do
481
485
  ENV['GITLAB_CI'] = 'yes'
482
486
  ENV['CI_BUILD_REF'] = 'gitlab-commit-sha'
@@ -495,6 +499,7 @@ RSpec.describe Percy::Client::Environment do
495
499
  expect(Percy::Client::Environment.repo).to eq('percy/percy-client') # From git, not env.
496
500
  end
497
501
  end
502
+
498
503
  describe 'local git repo methods' do
499
504
  describe '#commit' do
500
505
  it 'returns current local commit data' do
@@ -510,6 +515,7 @@ RSpec.describe Percy::Client::Environment do
510
515
  expect(commit[:committer_name]).to_not be_empty
511
516
  expect(commit[:message]).to_not be_empty
512
517
  end
518
+
513
519
  it 'returns only branch if commit data cannot be found' do
514
520
  expect(Percy::Client::Environment).to receive(:_raw_commit_output).once.and_return(nil)
515
521
 
@@ -524,6 +530,7 @@ RSpec.describe Percy::Client::Environment do
524
530
  expect(commit[:committer_name]).to be_nil
525
531
  expect(commit[:message]).to be_nil
526
532
  end
533
+
527
534
  it 'handles unicode characters in environment where LANG is not set' do
528
535
  output = "COMMIT_SHA:\nAUTHOR_NAME:Spêcìal Ñàme\nAUTHOR_EMAIL:\nCOMMITTER_NAME:\n" \
529
536
  "COMMITTER_EMAIL:\nCOMMITTED_DATE:\nCOMMIT_MESSAGE:".force_encoding('US-ASCII')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.5
4
+ version: 1.13.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-07 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -166,7 +166,7 @@ files:
166
166
  - percy-client.gemspec
167
167
  - spec/cassettes/Percy_Client_Builds/_create_build/accepts_optional_resources.yml
168
168
  - spec/cassettes/Percy_Client_Builds/_create_build/creates_a_build.yml
169
- - spec/cassettes/Percy_Client_Builds/_create_build/parallel_test_environment/passes_through_parallelism_variables.yml
169
+ - spec/cassettes/Percy_Client_Builds/_create_build/when_in_a_parallel_test_environment/passes_through_parallelism_variables.yml
170
170
  - spec/cassettes/Percy_Client_Builds/_finalize_build/finalizes_a_build.yml
171
171
  - spec/cassettes/Percy_Client_Resources/_upload_resource/returns_true_with_success.yml
172
172
  - spec/cassettes/Percy_Client_Snapshots/_create_snapshot/creates_a_snapshot.yml
@@ -210,7 +210,7 @@ summary: Percy::Client
210
210
  test_files:
211
211
  - spec/cassettes/Percy_Client_Builds/_create_build/accepts_optional_resources.yml
212
212
  - spec/cassettes/Percy_Client_Builds/_create_build/creates_a_build.yml
213
- - spec/cassettes/Percy_Client_Builds/_create_build/parallel_test_environment/passes_through_parallelism_variables.yml
213
+ - spec/cassettes/Percy_Client_Builds/_create_build/when_in_a_parallel_test_environment/passes_through_parallelism_variables.yml
214
214
  - spec/cassettes/Percy_Client_Builds/_finalize_build/finalizes_a_build.yml
215
215
  - spec/cassettes/Percy_Client_Resources/_upload_resource/returns_true_with_success.yml
216
216
  - spec/cassettes/Percy_Client_Snapshots/_create_snapshot/creates_a_snapshot.yml