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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/percy/capybara.rb +4 -0
- data/lib/percy/capybara/client.rb +6 -2
- data/lib/percy/capybara/version.rb +1 -1
- data/spec/lib/percy/capybara/client_spec.rb +21 -7
- data/spec/lib/percy/capybara_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af65d5970c1d8e9a7ad3fc82db10235d1ab5b6c3
|
4
|
+
data.tar.gz: 53046e99547f380834dc2a965b0943aa07e73f56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd0fc3b80bf5f6180eec99858c31a54fd8804639d5fc4e78fdfbc5dcbf9d5f41a74ded0ffa7e49ba0115ec81be1e04c46a3553fdc30e4ac7a40fa49bfa78e3c
|
7
|
+
data.tar.gz: 9c3fa55f7c6084535cb17cec37cc4aa387ffb946ad47f2f6ff6945757a21d59399e2e2ceb8004cfc53d27f3a279649105ced69d22ec90dbddf6a5eea818c2083
|
data/Gemfile.lock
CHANGED
data/lib/percy/capybara.rb
CHANGED
@@ -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
|
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
|
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
|
@@ -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
|
-
|
86
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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.
|
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-
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: percy-client
|