percy-capybara 1.1.0 → 1.2.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700625bc07e0be50c30a6e9838280e5b642395dc
|
4
|
+
data.tar.gz: f56557aaa8909e676cfbd638655ea506bcd99867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee826f8bab3a6f19233b7a85acade3509e62cf65fccfb82c21332eca520908b0579a3c03e099202cfeea0a700e7d21e001a2b0cdc70aef8efce8c10292dcf331
|
7
|
+
data.tar.gz: 340ddc44575e7bc6ceaed558494b94cef8e8cf2a4c7bf3e5e0499fe6d77047821d4cc25b91b8c7a0c433ebf0a729e19f57baef951fd2ad28d13fdd433209646b
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'percy/capybara/loaders/base_loader'
|
2
2
|
require 'digest'
|
3
|
+
require 'find'
|
3
4
|
require 'uri'
|
4
5
|
|
5
6
|
module Percy
|
@@ -30,6 +31,8 @@ module Percy
|
|
30
31
|
|
31
32
|
def build_resources
|
32
33
|
resources = []
|
34
|
+
|
35
|
+
# Load resources from the asset pipeline.
|
33
36
|
_asset_logical_paths.each do |logical_path|
|
34
37
|
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(logical_path))
|
35
38
|
|
@@ -48,12 +51,37 @@ module Percy
|
|
48
51
|
end
|
49
52
|
|
50
53
|
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(resource_url))
|
51
|
-
|
52
54
|
resources << Percy::Client::Resource.new(resource_url, sha: sha, content: content)
|
53
55
|
end
|
56
|
+
|
57
|
+
# Load resources from the public/ directory, if a Rails app.
|
58
|
+
if _rails
|
59
|
+
public_path = _rails.public_path.to_s
|
60
|
+
Find.find(public_path).each do |path|
|
61
|
+
# Skip directories.
|
62
|
+
next if !FileTest.file?(path)
|
63
|
+
# Skip certain extensions.
|
64
|
+
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(path))
|
65
|
+
|
66
|
+
# Strip the public_path from the beginning of the resource_url.
|
67
|
+
# This assumes that everything in the Rails public/ directory is served at the root
|
68
|
+
# of the app.
|
69
|
+
resource_url = path.sub(public_path, '')
|
70
|
+
|
71
|
+
sha = Digest::SHA256.hexdigest(File.read(path))
|
72
|
+
|
73
|
+
resources << Percy::Client::Resource.new(resource_url, sha: sha, path: path)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
54
78
|
resources
|
55
79
|
end
|
56
80
|
|
81
|
+
def _rails
|
82
|
+
return Rails if defined?(Rails)
|
83
|
+
end
|
84
|
+
|
57
85
|
def _asset_logical_paths
|
58
86
|
# Re-implement the same technique that "rake assets:precompile" uses to generate the
|
59
87
|
# list of asset paths to include in compiled assets. https://goo.gl/sy2R4z
|
@@ -55,5 +55,19 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
55
55
|
expect(resources.map { |r| r.resource_url }).to eq(["/assets/css/base.css"])
|
56
56
|
expect(resources.first.content).to include('.colored-by-base')
|
57
57
|
end
|
58
|
+
context 'Rails app' do
|
59
|
+
it 'includes files from the public folder (non-asset-pipeline)' do
|
60
|
+
|
61
|
+
# Pretend like we're in a Rails app right now, all we care about is Rails.public_path.
|
62
|
+
rails_double = double('Rails')
|
63
|
+
# Pretend like the entire testdata directory is the public/ folder.
|
64
|
+
expect(rails_double).to receive(:public_path).and_return(environment.root)
|
65
|
+
expect(loader).to receive(:_rails).at_least(:once).and_return(rails_double)
|
66
|
+
|
67
|
+
resources = loader.build_resources
|
68
|
+
expect(resources.length).to be > 5 # Weak test that more things are in this list.
|
69
|
+
expect(resources.map { |r| r.resource_url }).to include('/images/percy.svg')
|
70
|
+
end
|
71
|
+
end
|
58
72
|
end
|
59
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Perceptual Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: percy-client
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
version: '0'
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
230
|
+
rubygems_version: 2.4.5
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: Percy::Capybara
|
@@ -262,3 +262,4 @@ test_files:
|
|
262
262
|
- spec/lib/percy/capybara_spec.rb
|
263
263
|
- spec/spec_helper.rb
|
264
264
|
- spec/support/test_helpers.rb
|
265
|
+
has_rdoc:
|