percy-capybara 0.4.12 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/percy/capybara/client.rb +2 -0
- data/lib/percy/capybara/client/builds.rb +1 -0
- data/lib/percy/capybara/client/snapshots.rb +19 -1
- data/lib/percy/capybara/loaders/native_loader.rb +3 -0
- data/lib/percy/capybara/version.rb +1 -1
- data/percy-capybara.gemspec +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c2619a9098477489f443eed78751adf81401c66
|
4
|
+
data.tar.gz: 0c41b94845f31ddd1fe133c49749cd2bd76b36af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc1613a5a0614815620e004be594d50a833e0ffc2dda8633b9c61ab41a750062fc88f4aea5e7e81b0ba408060637eff0fc28bfd1f20d0727e863a7b1190b78a
|
7
|
+
data.tar.gz: 7f58f3e80ceffcb84feea0403f0f93bfe6d94e66cfbfeb15dd152ba03ebc82907783bb9c8495a6ed289bf0d8509405ae5119a05d2813155d1817314f0933cea4
|
@@ -40,10 +40,12 @@ module Percy
|
|
40
40
|
|
41
41
|
def initialize_loader(options = {})
|
42
42
|
if sprockets_environment && sprockets_options
|
43
|
+
Percy.logger.debug { 'Using sprockets_loader to discover assets.' }
|
43
44
|
options[:sprockets_environment] = sprockets_environment
|
44
45
|
options[:sprockets_options] = sprockets_options
|
45
46
|
Percy::Capybara::Loaders::SprocketsLoader.new(options)
|
46
47
|
else
|
48
|
+
Percy.logger.debug { 'Using native_loader to discover assets (slower).' }
|
47
49
|
Percy::Capybara::Loaders::NativeLoader.new(options)
|
48
50
|
end
|
49
51
|
end
|
@@ -3,6 +3,7 @@ require 'faraday'
|
|
3
3
|
require 'httpclient'
|
4
4
|
require 'digest'
|
5
5
|
require 'uri'
|
6
|
+
require 'time'
|
6
7
|
require 'pathname'
|
7
8
|
|
8
9
|
module Percy
|
@@ -18,27 +19,44 @@ module Percy
|
|
18
19
|
# entirely identify the current state.
|
19
20
|
def snapshot(page, options = {})
|
20
21
|
return if !enabled? # Silently skip if the client is disabled.
|
22
|
+
|
21
23
|
name = options[:name]
|
22
24
|
loader = initialize_loader(page: page)
|
23
25
|
|
26
|
+
Percy.logger.debug { "Snapshot started (name: #{name.inspect})" }
|
27
|
+
|
24
28
|
# If this is the first snapshot, create the build and upload build resources.
|
25
29
|
if !build_initialized?
|
30
|
+
start = Time.now
|
26
31
|
build_resources = loader.build_resources
|
32
|
+
if Percy.config.debug
|
33
|
+
build_resources.each do |build_resource|
|
34
|
+
Percy.logger.debug { "Build resource: #{build_resource.resource_url}" }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Percy.logger.debug { "All build resources loaded (#{Time.now - start}s)" }
|
27
38
|
initialize_build(resources: build_resources)
|
28
39
|
upload_missing_build_resources(build_resources)
|
29
40
|
end
|
30
41
|
|
42
|
+
start = Time.now
|
31
43
|
current_build_id = current_build['data']['id']
|
32
44
|
resources = loader.snapshot_resources
|
33
45
|
resource_map = {}
|
34
|
-
resources.each
|
46
|
+
resources.each do |r|
|
47
|
+
resource_map[r.sha] = r
|
48
|
+
Percy.logger.debug { "Snapshot resource: #{r.resource_url}" }
|
49
|
+
end
|
50
|
+
Percy.logger.debug { "All snapshot resources loaded (#{Time.now - start}s)" }
|
35
51
|
|
36
52
|
# Create the snapshot and upload any missing snapshot resources.
|
53
|
+
start = Time.now
|
37
54
|
snapshot = client.create_snapshot(current_build_id, resources, name: name)
|
38
55
|
snapshot['data']['relationships']['missing-resources']['data'].each do |missing_resource|
|
39
56
|
sha = missing_resource['id']
|
40
57
|
client.upload_resource(current_build_id, resource_map[sha].content)
|
41
58
|
end
|
59
|
+
Percy.logger.debug { "All snapshot resources uploaded (#{Time.now - start}s)" }
|
42
60
|
|
43
61
|
# Finalize the snapshot.
|
44
62
|
client.finalize_snapshot(snapshot['data']['id'])
|
@@ -148,6 +148,9 @@ module Percy
|
|
148
148
|
# will have no effect.
|
149
149
|
resource_url = URI.join(page.current_url, image_url).to_s
|
150
150
|
|
151
|
+
# Skip duplicates.
|
152
|
+
next if resources.find { |r| r.resource_url == resource_url }
|
153
|
+
|
151
154
|
next if !_should_include_url?(resource_url)
|
152
155
|
|
153
156
|
# Fetch the images.
|
data/percy-capybara.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'percy-client', '>= 0.
|
21
|
+
spec.add_dependency 'percy-client', '>= 0.8.0'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/spec/spec_helper.rb
CHANGED
@@ -47,6 +47,9 @@ RSpec.configure do |config|
|
|
47
47
|
WebMock.disable_net_connect!(allow_localhost: true, allow: [/i.imgur.com/])
|
48
48
|
end
|
49
49
|
|
50
|
+
# Cover all debug messages by outputting them in this gem's tests.
|
51
|
+
Percy.config.debug = true
|
52
|
+
|
50
53
|
# Start a temp webserver that serves the testdata directory.
|
51
54
|
# You can test this server manually by running:
|
52
55
|
# ruby -run -e httpd spec/lib/percy/capybara/client/testdata/ -p 9090
|
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: 0.
|
4
|
+
version: 0.5.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: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: percy-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|