percy-capybara 0.4.0 → 0.4.1

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: 0373826717cf4a83f083c9d8d71d92dfea1b595c
4
- data.tar.gz: e32236928c98afe4613579a5a9db5869ea506f90
3
+ metadata.gz: b08eef19753c6cf3c0933fe6b5cfc83bdd0f158a
4
+ data.tar.gz: 27a4c1eec39774d8d2319aa25917acc958c56b39
5
5
  SHA512:
6
- metadata.gz: bbc8b68ae8f7df03bc575f64cd6efa4c9bcb7bfbde16e478735e57d43b1e5d3bb64bd7e380db3025f81bc8c3bfdd7d8f0283b21da075258f98357ac94c9a15d9
7
- data.tar.gz: 053c1512eba240ff18904cb7790f5aa8093cc8356cfe086665be2b241ec9291679d2fb2d69a09ed790e055ee8f075ba652be3a26bed671ad23ffb2ec90eac5b6
6
+ metadata.gz: 2acc70ed15ac3efc0de81b79f02b11a123c38d1a8f6ed64fb0c434057ac93a99e2994196351c421da72ccf97af63345753fcb9943b9c024131ec95b919897584
7
+ data.tar.gz: d7f3b7eb44c7f88cc45cb8e6dc151bbd4807188e26c4d4ef8942918a9848bbb29c6241cec25955c9d7f055ba2141cf2cd417b3547a8140515b29124b28c659f3
@@ -16,14 +16,14 @@ module Percy
16
16
  current_build['data']['relationships']['missing-resources']['data']
17
17
  return 0 if !new_build_resources
18
18
 
19
- if !new_build_resources.empty?
20
- puts "[percy] Uploading #{new_build_resources.length} new resources..."
21
- end
22
- new_build_resources.each do |missing_resource|
19
+ new_build_resources.each_with_index do |missing_resource, i|
23
20
  sha = missing_resource['id']
24
21
  resource = build_resources.find { |r| r.sha == sha }
25
22
  content = resource.content || File.read(resource.path)
26
23
  client.upload_resource(current_build['data']['id'], content)
24
+ if i % 50 == 0
25
+ puts "[percy] Uploading #{i+1} of #{new_build_resources.length} new resources..."
26
+ end
27
27
  end
28
28
  new_build_resources.length
29
29
  end
@@ -24,6 +24,28 @@ module Percy
24
24
  end
25
25
 
26
26
  def build_resources
27
+ resources = []
28
+ _asset_logical_paths.each do |logical_path|
29
+ asset = sprockets_environment.find_asset(logical_path)
30
+ content = asset.to_s
31
+ sha = Digest::SHA256.hexdigest(content)
32
+
33
+ if defined?(ActionController)
34
+ # Ask Rails where this asset is (this handles asset_hosts, digest paths, etc.).
35
+ resource_url = ActionController::Base.helpers.asset_path(logical_path)
36
+ else
37
+ # TODO: more robust support for Sprockets usage outside Rails, ie Sinatra.
38
+ # How do we find the correct path in that case?
39
+ path = sprockets_options.digest ? asset.digest_path : logical_path
40
+ resource_url = URI.escape("/assets/#{path}")
41
+ end
42
+
43
+ resources << Percy::Client::Resource.new(resource_url, sha: sha, content: content)
44
+ end
45
+ resources
46
+ end
47
+
48
+ def _asset_logical_paths
27
49
  # Re-implement the same technique that "rake assets:precompile" uses to generate the
28
50
  # list of asset paths to include in compiled assets. https://goo.gl/sy2R4z
29
51
  # We can't just use environment.each_logical_path without any filters, because then
@@ -33,16 +55,6 @@ module Percy
33
55
  logical_paths += precompile_list.flatten.select do |filename|
34
56
  Pathname.new(filename).absolute? if filename.is_a?(String)
35
57
  end
36
-
37
- resources = []
38
- logical_paths.each do |logical_path|
39
- content = sprockets_environment.find_asset(logical_path).to_s
40
- sha = Digest::SHA256.hexdigest(content)
41
- resource_url = URI.escape("/assets/#{logical_path}")
42
- resources << Percy::Client::Resource.new(
43
- resource_url, sha: sha, content: content)
44
- end
45
- resources
46
58
  end
47
59
  end
48
60
  end
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  module Capybara
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
@@ -23,6 +23,7 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
23
23
  let(:sprockets_options) do
24
24
  options = double('options')
25
25
  allow(options).to receive(:precompile).and_return([/(?:\/|\\|\A)base\.(css|js)$/])
26
+ allow(options).to receive(:digest).and_return(false)
26
27
  options
27
28
  end
28
29
 
@@ -41,6 +41,7 @@ module TestHelpers
41
41
 
42
42
  sprockets_options = double('sprockets_options')
43
43
  allow(sprockets_options).to receive(:precompile).and_return([/(?:\/|\\|\A)base\.(css|js)$/])
44
+ allow(sprockets_options).to receive(:digest).and_return(false)
44
45
 
45
46
  capybara_client.sprockets_environment = environment
46
47
  capybara_client.sprockets_options = sprockets_options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.