percy-capybara 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/percy/capybara/loaders/base_loader.rb +17 -3
- data/lib/percy/capybara/loaders/sprockets_loader.rb +2 -17
- data/lib/percy/capybara/version.rb +1 -1
- data/spec/lib/percy/capybara/client/{test_data/public → rails_public_test_data}/large-file-skipped.png +0 -0
- data/spec/lib/percy/capybara/client/{test_data/public → rails_public_test_data}/percy-from-public.svg +0 -0
- data/spec/lib/percy/capybara/client/rails_public_test_data/symlink_to_images +1 -0
- data/spec/lib/percy/capybara/client/symlink_test_data/test.png +0 -0
- data/spec/lib/percy/capybara/loaders/filesystem_loader_spec.rb +0 -2
- data/spec/lib/percy/capybara/loaders/sprockets_loader_spec.rb +9 -3
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40bc91d41c82651dd6873aa89f1680b7fb85560b
|
4
|
+
data.tar.gz: a324146ad3bafa211c29c412e36f91d41051ff2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26dd09ccac1d8f7770ad95ea97699e9f876570701c67e1779ecfb7ebda990a6856df23f3443f2cad7cedade62853e97d189fe0304a9a55ee9b659e93e37d9a6d
|
7
|
+
data.tar.gz: 7c6c5452139cc6c948447264740158eafd5b1f6a16b44931b4ea8402129d358c174c3f32b2faed1cb9994002bfdbeb679179ebba27769aa4d58d1bcb37adc5e5
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pathname'
|
1
2
|
require 'percy/capybara'
|
2
3
|
|
3
4
|
module Percy
|
@@ -124,9 +125,7 @@ module Percy
|
|
124
125
|
def _resources_from_dir(root_dir, base_url: '/')
|
125
126
|
resources = []
|
126
127
|
|
127
|
-
|
128
|
-
# Skip directories.
|
129
|
-
next unless FileTest.file?(path)
|
128
|
+
_find_files(root_dir).each do |path|
|
130
129
|
# Skip certain extensions.
|
131
130
|
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(path))
|
132
131
|
# Skip large files, these are hopefully downloads and not used in page rendering.
|
@@ -143,6 +142,21 @@ module Percy
|
|
143
142
|
resources
|
144
143
|
end
|
145
144
|
|
145
|
+
# A simplified version of Find.find that only returns files and follows symlinks.
|
146
|
+
def _find_files(*paths)
|
147
|
+
paths.flatten!
|
148
|
+
paths.map! { |p| Pathname.new(p) }
|
149
|
+
files = []
|
150
|
+
paths.each do |path|
|
151
|
+
if path.file?
|
152
|
+
files << path.to_s
|
153
|
+
else
|
154
|
+
files = files.concat(_find_files(path.children))
|
155
|
+
end
|
156
|
+
end
|
157
|
+
files
|
158
|
+
end
|
159
|
+
|
146
160
|
def _uri_join(*paths)
|
147
161
|
# We must swap File::SEPARATOR for '/' here because on Windows File.join
|
148
162
|
# will use backslashes and this is a URL.
|
@@ -64,24 +64,9 @@ module Percy
|
|
64
64
|
# Load resources from the public/ directory, if a Rails app.
|
65
65
|
if _rails
|
66
66
|
public_path = _rails.public_path.to_s
|
67
|
-
|
68
|
-
# Skip directories.
|
69
|
-
next unless FileTest.file?(path)
|
70
|
-
# Skip certain extensions.
|
71
|
-
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(path))
|
72
|
-
# Skip large files, these are hopefully downloads and not used in page rendering.
|
73
|
-
next if File.size(path) > MAX_FILESIZE_BYTES
|
74
|
-
|
75
|
-
# Strip the public_path from the beginning of the resource_url.
|
76
|
-
# This assumes that everything in the Rails public/ directory is served at the root
|
77
|
-
# of the app.
|
78
|
-
resource_url = path.sub(public_path, '')
|
79
|
-
|
67
|
+
resources += _resources_from_dir(public_path).reject do |resource|
|
80
68
|
# Skip precompiled files already included via the asset pipeline.
|
81
|
-
|
82
|
-
|
83
|
-
sha = Digest::SHA256.hexdigest(File.read(path))
|
84
|
-
resources << Percy::Client::Resource.new(resource_url, sha: sha, path: path)
|
69
|
+
loaded_resource_urls.include?(resource.resource_url)
|
85
70
|
end
|
86
71
|
end
|
87
72
|
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
spec/lib/percy/capybara/client/rails_public_test_data/../symlink_test_data
|
Binary file
|
@@ -71,7 +71,6 @@ RSpec.describe Percy::Capybara::Loaders::FilesystemLoader do
|
|
71
71
|
'/images/srcset-second.png',
|
72
72
|
'/index.html',
|
73
73
|
'/js/base.js',
|
74
|
-
'/public/percy-from-public.svg',
|
75
74
|
'/test-css.html',
|
76
75
|
'/test-font.html',
|
77
76
|
'/test-iframe.html',
|
@@ -104,7 +103,6 @@ RSpec.describe Percy::Capybara::Loaders::FilesystemLoader do
|
|
104
103
|
'/url-prefix/images/srcset-second.png',
|
105
104
|
'/url-prefix/index.html',
|
106
105
|
'/url-prefix/js/base.js',
|
107
|
-
'/url-prefix/public/percy-from-public.svg',
|
108
106
|
'/url-prefix/test-css.html',
|
109
107
|
'/url-prefix/test-font.html',
|
110
108
|
'/url-prefix/test-iframe.html',
|
@@ -7,6 +7,12 @@ class SimpleRackApp
|
|
7
7
|
end
|
8
8
|
|
9
9
|
RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
10
|
+
let(:test_data_path) do
|
11
|
+
File.expand_path('../../client/test_data', __FILE__)
|
12
|
+
end
|
13
|
+
let(:rails_public_test_data_path) do
|
14
|
+
File.expand_path('../../client/rails_public_test_data', __FILE__)
|
15
|
+
end
|
10
16
|
let(:loader) do
|
11
17
|
described_class.new(
|
12
18
|
page: page,
|
@@ -15,8 +21,7 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
15
21
|
)
|
16
22
|
end
|
17
23
|
let(:environment) do
|
18
|
-
|
19
|
-
environment = Sprockets::Environment.new(root)
|
24
|
+
environment = Sprockets::Environment.new(test_data_path)
|
20
25
|
environment.append_path '.'
|
21
26
|
environment
|
22
27
|
end
|
@@ -78,7 +83,7 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
78
83
|
rails_double = double('Rails')
|
79
84
|
# Pretend like the entire test_data directory is the public/ folder.
|
80
85
|
expect(rails_double).to receive(:application).and_return(nil)
|
81
|
-
expect(rails_double).to receive(:public_path).and_return(
|
86
|
+
expect(rails_double).to receive(:public_path).and_return(rails_public_test_data_path)
|
82
87
|
expect(loader).to receive(:_rails).at_least(:once).and_return(rails_double)
|
83
88
|
end
|
84
89
|
it 'includes files from the public folder (non-asset-pipeline)' do
|
@@ -89,6 +94,7 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
89
94
|
resource_urls = resources.map(&:resource_url)
|
90
95
|
expect(resource_urls).to include('/assets/images/bg-relative.png') # From asset pipeline.
|
91
96
|
expect(resource_urls).to include('/percy-from-public.svg') # Public merged into root.
|
97
|
+
expect(resource_urls).to include('/symlink_to_images/test.png') # Symlink in public dir.
|
92
98
|
expect(resource_urls).not_to include('/large-file-skipped.png') # Public merged into root.
|
93
99
|
end
|
94
100
|
context 'digest enabled' do
|
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: 3.0.
|
4
|
+
version: 3.0.1
|
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-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: percy-client
|
@@ -204,7 +204,11 @@ files:
|
|
204
204
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/assets/percy-frontend.svg
|
205
205
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/index.html
|
206
206
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/percy-frontend-public.svg
|
207
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/large-file-skipped.png
|
208
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/percy-from-public.svg
|
209
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/symlink_to_images
|
207
210
|
- spec/lib/percy/capybara/client/snapshots_spec.rb
|
211
|
+
- spec/lib/percy/capybara/client/symlink_test_data/test.png
|
208
212
|
- spec/lib/percy/capybara/client/test_data/assets/css/digested-f3420c6aee71c137a3ca39727052811bae84b2f37d898f4db242e20656a1579e.css
|
209
213
|
- spec/lib/percy/capybara/client/test_data/assets/images/large-file-skipped.png
|
210
214
|
- spec/lib/percy/capybara/client/test_data/css/base.css
|
@@ -228,8 +232,6 @@ files:
|
|
228
232
|
- spec/lib/percy/capybara/client/test_data/images/srcset-second.png
|
229
233
|
- spec/lib/percy/capybara/client/test_data/index.html
|
230
234
|
- spec/lib/percy/capybara/client/test_data/js/base.js
|
231
|
-
- spec/lib/percy/capybara/client/test_data/public/large-file-skipped.png
|
232
|
-
- spec/lib/percy/capybara/client/test_data/public/percy-from-public.svg
|
233
235
|
- spec/lib/percy/capybara/client/test_data/test-css.html
|
234
236
|
- spec/lib/percy/capybara/client/test_data/test-font.html
|
235
237
|
- spec/lib/percy/capybara/client/test_data/test-iframe.html
|
@@ -265,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
267
|
version: '0'
|
266
268
|
requirements: []
|
267
269
|
rubyforge_project:
|
268
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.6.7
|
269
271
|
signing_key:
|
270
272
|
specification_version: 4
|
271
273
|
summary: Percy::Capybara
|
@@ -277,7 +279,11 @@ test_files:
|
|
277
279
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/assets/percy-frontend.svg
|
278
280
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/index.html
|
279
281
|
- spec/lib/percy/capybara/client/ember_test_data/ember-cli/frontend/percy-frontend-public.svg
|
282
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/large-file-skipped.png
|
283
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/percy-from-public.svg
|
284
|
+
- spec/lib/percy/capybara/client/rails_public_test_data/symlink_to_images
|
280
285
|
- spec/lib/percy/capybara/client/snapshots_spec.rb
|
286
|
+
- spec/lib/percy/capybara/client/symlink_test_data/test.png
|
281
287
|
- spec/lib/percy/capybara/client/test_data/assets/css/digested-f3420c6aee71c137a3ca39727052811bae84b2f37d898f4db242e20656a1579e.css
|
282
288
|
- spec/lib/percy/capybara/client/test_data/assets/images/large-file-skipped.png
|
283
289
|
- spec/lib/percy/capybara/client/test_data/css/base.css
|
@@ -301,8 +307,6 @@ test_files:
|
|
301
307
|
- spec/lib/percy/capybara/client/test_data/images/srcset-second.png
|
302
308
|
- spec/lib/percy/capybara/client/test_data/index.html
|
303
309
|
- spec/lib/percy/capybara/client/test_data/js/base.js
|
304
|
-
- spec/lib/percy/capybara/client/test_data/public/large-file-skipped.png
|
305
|
-
- spec/lib/percy/capybara/client/test_data/public/percy-from-public.svg
|
306
310
|
- spec/lib/percy/capybara/client/test_data/test-css.html
|
307
311
|
- spec/lib/percy/capybara/client/test_data/test-font.html
|
308
312
|
- spec/lib/percy/capybara/client/test_data/test-iframe.html
|