percy-capybara 2.1.1 → 2.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: 6498403c9a10399a29d67eafa17d576300d62fa1
4
- data.tar.gz: 5159d6ff409edac2d447b71990050b46b235f6e8
3
+ metadata.gz: af65d5970c1d8e9a7ad3fc82db10235d1ab5b6c3
4
+ data.tar.gz: 53046e99547f380834dc2a965b0943aa07e73f56
5
5
  SHA512:
6
- metadata.gz: 24ca4f78314dbfd15f3575b1199a56713c79b11909b863e9e932cfe1c11e3ef3bf6111e50b6f49100f35949b4498eab23055a2bc930ffab8e2db08bab4064123
7
- data.tar.gz: 57f2014995d9afc020debf852b4f0829c9b20564c8a831f22c257f43e7ab550d7b6fee9955000fb36cb91645585c7919197ee9a839cc4d42b1bcfacde07ce88e
6
+ metadata.gz: 2bd0fc3b80bf5f6180eec99858c31a54fd8804639d5fc4e78fdfbc5dcbf9d5f41a74ded0ffa7e49ba0115ec81be1e04c46a3553fdc30e4ac7a40fa49bfa78e3c
7
+ data.tar.gz: 9c3fa55f7c6084535cb17cec37cc4aa387ffb946ad47f2f6ff6945757a21d59399e2e2ceb8004cfc53d27f3a279649105ced69d22ec90dbddf6a5eea818c2083
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- percy-capybara (2.1.1)
4
+ percy-capybara (2.2.0)
5
5
  percy-client (~> 1.4)
6
6
 
7
7
  GEM
@@ -52,5 +52,9 @@ module Percy
52
52
  def self.disable!
53
53
  capybara_client.disable!
54
54
  end
55
+
56
+ def self.use_loader(loader)
57
+ capybara_client.custom_loader = loader
58
+ end
55
59
  end
56
60
  end
@@ -17,6 +17,7 @@ module Percy
17
17
 
18
18
  attr_accessor :sprockets_environment
19
19
  attr_accessor :sprockets_options
20
+ attr_accessor :custom_loader
20
21
 
21
22
  def initialize(options = {})
22
23
  @client = options[:client] || Percy.client
@@ -43,7 +44,7 @@ module Percy
43
44
  end
44
45
 
45
46
  def rescue_connection_failures(&block)
46
- raise ArgumentError.new('block is requried') if !block_given?
47
+ raise ArgumentError.new('block is required') if !block_given?
47
48
  begin
48
49
  block.call
49
50
  rescue Percy::Client::ServerError, # Rescue server errors.
@@ -62,7 +63,10 @@ module Percy
62
63
  end
63
64
 
64
65
  def initialize_loader(options = {})
65
- if sprockets_environment && sprockets_options
66
+ if custom_loader
67
+ Percy.logger.debug { 'Using a custom loader to discover assets.' }
68
+ custom_loader.new(options)
69
+ elsif sprockets_environment && sprockets_options
66
70
  Percy.logger.debug { 'Using sprockets_loader to discover assets.' }
67
71
  options[:sprockets_environment] = sprockets_environment
68
72
  options[:sprockets_options] = sprockets_options
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  module Capybara
3
- VERSION = '2.1.1'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
@@ -82,14 +82,28 @@ RSpec.describe Percy::Capybara::Client do
82
82
  describe '#initialize_loader' do
83
83
  let(:capybara_client) { Percy::Capybara::Client.new }
84
84
 
85
- it 'returns a NativeLoader if no sprockets config' do
86
- expect(capybara_client.initialize_loader.class).to eq(Percy::Capybara::Loaders::NativeLoader)
85
+ context 'when a custom loader has been set' do
86
+ it 'returns an instance of the clients custom loader' do
87
+ class DummyLoader < Percy::Capybara::Loaders::NativeLoader; end
88
+ capybara_client.custom_loader = DummyLoader
89
+ loader = capybara_client.initialize_loader
90
+ expect(loader.class).to eq(DummyLoader)
91
+ end
92
+ end
93
+
94
+ context 'when sprockets is configured' do
95
+ it 'returns a SprocketsLoader' do
96
+ capybara_client.sprockets_environment = double('sprockets_environment')
97
+ capybara_client.sprockets_options = double('sprockets_options')
98
+ loader = capybara_client.initialize_loader
99
+ expect(loader.class).to eq(Percy::Capybara::Loaders::SprocketsLoader)
100
+ end
87
101
  end
88
- it 'returns a SprocketsLoader if sprockets is configured' do
89
- capybara_client.sprockets_environment = double('sprockets_environment')
90
- capybara_client.sprockets_options = double('sprockets_options')
91
- loader = capybara_client.initialize_loader
92
- expect(loader.class).to eq(Percy::Capybara::Loaders::SprocketsLoader)
102
+
103
+ context 'when no configuration has been set' do
104
+ it 'returns a NativeLoader' do
105
+ expect(capybara_client.initialize_loader.class).to eq(Percy::Capybara::Loaders::NativeLoader)
106
+ end
93
107
  end
94
108
  end
95
109
  end
@@ -76,4 +76,14 @@ RSpec.describe Percy::Capybara do
76
76
  expect(Percy::Capybara.capybara_client.enabled?).to eq(false)
77
77
  end
78
78
  end
79
+ describe '#use_loader' do
80
+ class DummyLoader < Percy::Capybara::Loaders::NativeLoader; end
81
+
82
+ it 'sets the current capybara clients custom loader' do
83
+ capybara_client = Percy::Capybara::Client
84
+ expect(Percy::Capybara.capybara_client.custom_loader).to_not be
85
+ Percy::Capybara.use_loader(DummyLoader)
86
+ expect(Percy::Capybara.capybara_client.custom_loader).to be
87
+ end
88
+ end
79
89
  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: 2.1.1
4
+ version: 2.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: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: percy-client