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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0b53ea049a7cd739dd11324879b1d408b3e7e26
4
- data.tar.gz: 1f4cec79e9afe311ea950875effc68a50e4f09bd
3
+ metadata.gz: 4c2619a9098477489f443eed78751adf81401c66
4
+ data.tar.gz: 0c41b94845f31ddd1fe133c49749cd2bd76b36af
5
5
  SHA512:
6
- metadata.gz: 35561bd7f8d6dde6ea3b7fbd38f89405f939d02cacd900deb55edd7593a23b5d91296d2ff3ffa40f94df72861000b885298a4618906796d6a399be276b1ae6aa
7
- data.tar.gz: b1b58fbcf54f31d651ce15e629fbd777a5b268d4c00066cf37f8fc9439dea2f42e0f1a493ebf1b3726169de35c2bb7ac6ca56e155a2c1b2974ab7032198c6a57
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
@@ -5,6 +5,7 @@ module Percy
5
5
  def current_build(options = {})
6
6
  return if !enabled? # Silently skip if the client is disabled.
7
7
  @current_build ||= client.create_build(client.config.repo, options)
8
+ @current_build
8
9
  end
9
10
  alias_method :initialize_build, :current_build
10
11
 
@@ -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 { |r| resource_map[r.sha] = r }
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.
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  module Capybara
3
- VERSION = '0.4.12'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -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.4.1'
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'
@@ -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.12
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-09-23 00:00:00.000000000 Z
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.4.1
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.4.1
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement