percy-capybara 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +42 -0
- data/.rubocop_todo.yml +98 -0
- data/.travis.yml +4 -1
- data/Gemfile +6 -1
- data/Rakefile +0 -1
- data/lib/percy/capybara.rb +2 -2
- data/lib/percy/capybara/client.rb +20 -22
- data/lib/percy/capybara/client/builds.rb +13 -13
- data/lib/percy/capybara/client/snapshots.rb +9 -10
- data/lib/percy/capybara/httpfetcher.rb +7 -7
- data/lib/percy/capybara/loaders/base_loader.rb +17 -16
- data/lib/percy/capybara/loaders/filesystem_loader.rb +10 -11
- data/lib/percy/capybara/loaders/native_loader.rb +14 -13
- data/lib/percy/capybara/loaders/sprockets_loader.rb +6 -6
- data/lib/percy/capybara/version.rb +1 -1
- data/percy-capybara.gemspec +1 -1
- data/spec/lib/percy/capybara/client/builds_spec.rb +10 -8
- data/spec/lib/percy/capybara/client/snapshots_spec.rb +12 -10
- data/spec/lib/percy/capybara/client_spec.rb +5 -4
- data/spec/lib/percy/capybara/{httpfetcher_spec.rb → http_fetcher_spec.rb} +2 -2
- data/spec/lib/percy/capybara/loaders/base_loader_spec.rb +3 -5
- data/spec/lib/percy/capybara/loaders/filesystem_loader_spec.rb +9 -5
- data/spec/lib/percy/capybara/loaders/native_loader_spec.rb +41 -41
- data/spec/lib/percy/capybara/loaders/sprockets_loader_spec.rb +14 -13
- data/spec/lib/percy/capybara_spec.rb +8 -8
- data/spec/spec_helper.rb +1 -1
- data/spec/support/test_helpers.rb +3 -3
- metadata +12 -4
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'sprockets'
|
2
2
|
|
3
3
|
class SimpleRackApp
|
4
|
-
def self.call(
|
4
|
+
def self.call(_env)
|
5
5
|
[200, {}, 'Hello World']
|
6
6
|
end
|
7
7
|
end
|
@@ -11,11 +11,11 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
11
11
|
described_class.new(
|
12
12
|
page: page,
|
13
13
|
sprockets_environment: environment,
|
14
|
-
sprockets_options: sprockets_options
|
14
|
+
sprockets_options: sprockets_options
|
15
15
|
)
|
16
16
|
end
|
17
17
|
let(:environment) do
|
18
|
-
root = File.expand_path(
|
18
|
+
root = File.expand_path('../../client/testdata', __FILE__)
|
19
19
|
environment = Sprockets::Environment.new(root)
|
20
20
|
environment.append_path '.'
|
21
21
|
environment
|
@@ -32,12 +32,12 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
32
32
|
|
33
33
|
describe '#snapshot_resources' do
|
34
34
|
context 'Rack::Test', type: :feature do
|
35
|
-
before
|
35
|
+
before { Capybara.app = SimpleRackApp }
|
36
36
|
|
37
37
|
it 'returns the root HTML resource' do
|
38
38
|
visit '/'
|
39
39
|
resources = loader.snapshot_resources
|
40
|
-
expect(resources.map
|
40
|
+
expect(resources.map(&:resource_url)).to eq(['/'])
|
41
41
|
expect(resources.first.is_root).to eq(true)
|
42
42
|
expect(resources.first.content).to include('Hello World')
|
43
43
|
end
|
@@ -46,7 +46,7 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
46
46
|
it 'returns the root HTML resource' do
|
47
47
|
visit '/'
|
48
48
|
resources = loader.snapshot_resources
|
49
|
-
expect(resources.map
|
49
|
+
expect(resources.map(&:resource_url)).to eq(['/'])
|
50
50
|
expect(resources.first.is_root).to eq(true)
|
51
51
|
expect(resources.first.content).to include('Hello World!</body></html>')
|
52
52
|
end
|
@@ -69,11 +69,11 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
69
69
|
'/assets/images/srcset-second.png',
|
70
70
|
'/assets/js/base.js',
|
71
71
|
]
|
72
|
-
expect(resources.map
|
72
|
+
expect(resources.map(&:resource_url)).to eq(expected_resources)
|
73
73
|
expect(resources.first.content).to include('.colored-by-base')
|
74
74
|
end
|
75
75
|
context 'Rails app' do
|
76
|
-
before
|
76
|
+
before do
|
77
77
|
# Pretend like we're in a Rails app right now, all we care about is Rails.public_path.
|
78
78
|
rails_double = double('Rails')
|
79
79
|
# Pretend like the entire testdata directory is the public/ folder.
|
@@ -85,10 +85,10 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
85
85
|
# Weak test that more things are in this list, because it merges asset pipeline with public.
|
86
86
|
expect(resources.length).to be > 5
|
87
87
|
|
88
|
-
resource_urls = resources.map
|
89
|
-
expect(resource_urls).to include('/assets/images/bg-relative.png')
|
90
|
-
expect(resource_urls).to include('/percy-from-public.svg')
|
91
|
-
expect(resource_urls).
|
88
|
+
resource_urls = resources.map(&:resource_url)
|
89
|
+
expect(resource_urls).to include('/assets/images/bg-relative.png') # From asset pipeline.
|
90
|
+
expect(resource_urls).to include('/percy-from-public.svg') # Public merged into root.
|
91
|
+
expect(resource_urls).not_to include('/large-file-skipped.png') # Public merged into root.
|
92
92
|
end
|
93
93
|
context 'digest enabled' do
|
94
94
|
let(:digest_enabled) { true }
|
@@ -99,7 +99,8 @@ RSpec.describe Percy::Capybara::Loaders::SprocketsLoader do
|
|
99
99
|
# `config.assets.digest = true` set can safely run "rake assets:precompile" before tests.
|
100
100
|
resources = loader.build_resources
|
101
101
|
expected_digest_url = \
|
102
|
-
'/assets/css/digested-
|
102
|
+
'/assets/css/digested-f3420c6aee71c137a3ca39727052811bae84b2f37' \
|
103
|
+
'd898f4db242e20656a1579e.css'
|
103
104
|
digested_resources = resources.select { |r| r.resource_url == expected_digest_url }
|
104
105
|
expect(digested_resources.length).to eq(1)
|
105
106
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
RSpec.describe Percy::Capybara do
|
2
|
-
before
|
2
|
+
before do
|
3
3
|
Percy::Capybara.reset!
|
4
4
|
@original_env = ENV['TRAVIS_BUILD_ID']
|
5
5
|
ENV['TRAVIS_BUILD_ID'] = nil
|
6
6
|
end
|
7
|
-
after
|
7
|
+
after do
|
8
8
|
ENV['TRAVIS_BUILD_ID'] = @original_env
|
9
9
|
ENV.delete('PERCY_ENABLE')
|
10
10
|
end
|
@@ -41,7 +41,7 @@ RSpec.describe Percy::Capybara do
|
|
41
41
|
end
|
42
42
|
describe '#finalize_build' do
|
43
43
|
it 'returns silently if no build is initialized' do
|
44
|
-
expect { Percy::Capybara.finalize_build }.
|
44
|
+
expect { Percy::Capybara.finalize_build }.not_to raise_error
|
45
45
|
end
|
46
46
|
it 'delegates to Percy::Capybara::Client' do
|
47
47
|
capybara_client = Percy::Capybara.capybara_client
|
@@ -55,9 +55,9 @@ RSpec.describe Percy::Capybara do
|
|
55
55
|
it 'silently skips if disabled' do
|
56
56
|
ENV['PERCY_ENABLE'] = '0'
|
57
57
|
capybara_client = Percy::Capybara.capybara_client
|
58
|
-
expect(capybara_client.client).
|
58
|
+
expect(capybara_client.client).not_to receive(:create_build)
|
59
59
|
Percy::Capybara.initialize_build
|
60
|
-
expect(capybara_client).
|
60
|
+
expect(capybara_client).not_to receive(:finalize_current_build)
|
61
61
|
Percy::Capybara.finalize_build
|
62
62
|
end
|
63
63
|
end
|
@@ -65,7 +65,7 @@ RSpec.describe Percy::Capybara do
|
|
65
65
|
it 'clears the current capybara_client' do
|
66
66
|
capybara_client = Percy::Capybara.capybara_client
|
67
67
|
Percy::Capybara.reset!
|
68
|
-
expect(Percy::Capybara.capybara_client).
|
68
|
+
expect(Percy::Capybara.capybara_client).not_to eq(capybara_client)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
describe '#disable!' do
|
@@ -82,14 +82,14 @@ RSpec.describe Percy::Capybara do
|
|
82
82
|
class DummyLoader < Percy::Capybara::Loaders::NativeLoader; end
|
83
83
|
|
84
84
|
it 'sets the current capybara client\'s loader' do
|
85
|
-
expect(Percy::Capybara.capybara_client.loader).
|
85
|
+
expect(Percy::Capybara.capybara_client.loader).not_to be
|
86
86
|
Percy::Capybara.use_loader(DummyLoader)
|
87
87
|
expect(Percy::Capybara.capybara_client.loader).to be
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'sets the current capybara client\'s loader options' do
|
91
91
|
expect(Percy::Capybara.capybara_client.loader_options).to eq({})
|
92
|
-
Percy::Capybara.use_loader(DummyLoader,
|
92
|
+
Percy::Capybara.use_loader(DummyLoader, test_option: 3)
|
93
93
|
expect(Percy::Capybara.capybara_client.loader_options).to be
|
94
94
|
expect(Percy::Capybara.capybara_client.loader_options[:test_option]).to eq(3)
|
95
95
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -55,7 +55,7 @@ RSpec.configure do |config|
|
|
55
55
|
# You can test this server manually by running:
|
56
56
|
# ruby -run -e httpd spec/lib/percy/capybara/client/testdata/ -p 9090
|
57
57
|
config.before(:all, type: :feature) do
|
58
|
-
port =
|
58
|
+
port = random_open_port
|
59
59
|
Capybara.app = nil
|
60
60
|
Capybara.app_host = "http://localhost:#{port}"
|
61
61
|
Capybara.run_server = false
|
@@ -3,9 +3,9 @@ require 'timeout'
|
|
3
3
|
require 'sprockets'
|
4
4
|
|
5
5
|
module TestHelpers
|
6
|
-
class ServerDown <
|
6
|
+
class ServerDown < RuntimeError; end
|
7
7
|
|
8
|
-
def
|
8
|
+
def random_open_port
|
9
9
|
# Using a port of "0" relies on the system to pick an open port.
|
10
10
|
server = TCPServer.new('127.0.0.1', 0)
|
11
11
|
port = server.addr[1]
|
@@ -35,7 +35,7 @@ module TestHelpers
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def setup_sprockets(capybara_client)
|
38
|
-
root = File.expand_path(
|
38
|
+
root = File.expand_path('../../lib/percy/capybara/client/testdata', __FILE__)
|
39
39
|
environment = Sprockets::Environment.new(root)
|
40
40
|
environment.append_path '.'
|
41
41
|
|
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.
|
4
|
+
version: 2.4.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-02-
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: percy-client
|
@@ -87,6 +87,9 @@ dependencies:
|
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.6'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.12.0
|
90
93
|
type: :development
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -94,6 +97,9 @@ dependencies:
|
|
94
97
|
- - ">="
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '1.6'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.12.0
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: selenium-webdriver
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +179,8 @@ extra_rdoc_files: []
|
|
173
179
|
files:
|
174
180
|
- ".gitignore"
|
175
181
|
- ".rspec"
|
182
|
+
- ".rubocop.yml"
|
183
|
+
- ".rubocop_todo.yml"
|
176
184
|
- ".travis.yml"
|
177
185
|
- ".yardopts"
|
178
186
|
- CHANGELOG.md
|
@@ -224,7 +232,7 @@ files:
|
|
224
232
|
- spec/lib/percy/capybara/client/testdata/test-images.html
|
225
233
|
- spec/lib/percy/capybara/client/testdata/test-localtest-me-images.html
|
226
234
|
- spec/lib/percy/capybara/client_spec.rb
|
227
|
-
- spec/lib/percy/capybara/
|
235
|
+
- spec/lib/percy/capybara/http_fetcher_spec.rb
|
228
236
|
- spec/lib/percy/capybara/loaders/base_loader_spec.rb
|
229
237
|
- spec/lib/percy/capybara/loaders/filesystem_loader_spec.rb
|
230
238
|
- spec/lib/percy/capybara/loaders/native_loader_spec.rb
|
@@ -288,7 +296,7 @@ test_files:
|
|
288
296
|
- spec/lib/percy/capybara/client/testdata/test-images.html
|
289
297
|
- spec/lib/percy/capybara/client/testdata/test-localtest-me-images.html
|
290
298
|
- spec/lib/percy/capybara/client_spec.rb
|
291
|
-
- spec/lib/percy/capybara/
|
299
|
+
- spec/lib/percy/capybara/http_fetcher_spec.rb
|
292
300
|
- spec/lib/percy/capybara/loaders/base_loader_spec.rb
|
293
301
|
- spec/lib/percy/capybara/loaders/filesystem_loader_spec.rb
|
294
302
|
- spec/lib/percy/capybara/loaders/native_loader_spec.rb
|