percy-capybara 5.0.0.pre.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -0
- data/lib/percy/capybara.rb +7 -5
- data/lib/percy/version.rb +1 -1
- metadata +5 -26
- data/.github/dependabot.yml +0 -8
- data/.github/release-drafter.yml +0 -31
- data/.github/workflows/changelog.yml +0 -11
- data/.github/workflows/lint.yml +0 -22
- data/.github/workflows/release.yml +0 -22
- data/.github/workflows/test.yml +0 -26
- data/.gitignore +0 -17
- data/.rspec +0 -4
- data/.rubocop.yml +0 -13
- data/.yardopts +0 -2
- data/Gemfile +0 -16
- data/Guardfile +0 -14
- data/Makefile +0 -3
- data/Rakefile +0 -1
- data/percy-capybara.gemspec +0 -32
- data/spec/fixture/index.html +0 -1
- data/spec/lib/percy/percy_capybara_spec.rb +0 -103
- data/spec/spec_helper.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45a545941cfa1347d8912e8d94218005a87662f1c07d7633696ed56ba130a319
|
4
|
+
data.tar.gz: e0796a2c700b35b7710c79979ea1d12c136335fce31b3d12c1e68630bd56ba88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cb49cda9b878968ffb3225c032c5a49e8c8fc712c9598c0c654362dad01a46d8d1f1808a4bef1cc3c2a6593b5da28f0deb7e1484a00416f2aa2ba9d7eaaf0f2
|
7
|
+
data.tar.gz: 45bd57d38c20a550fe956c4b99b13b4d271113b5a8e14ef5b9e832facf36fe2be09b60e8a6ca5539ee54bde4b5885e67fdc6315d33cb75e46abf2e19e92b5757
|
data/README.md
CHANGED
@@ -70,6 +70,23 @@ $ percy exec -- [test command]
|
|
70
70
|
|
71
71
|
## Upgrading
|
72
72
|
|
73
|
+
### Automatically with `@percy/migrate`
|
74
|
+
|
75
|
+
We built a tool to help automate migrating to the new CLI toolchain! Migrating
|
76
|
+
can be done by running the following commands and following the prompts:
|
77
|
+
|
78
|
+
``` shell
|
79
|
+
$ npx @percy/migrate
|
80
|
+
? Are you currently using percy-capybara? Yes
|
81
|
+
? Install @percy/cli (required to run percy)? Yes
|
82
|
+
? Migrate Percy config file? Yes
|
83
|
+
? Upgrade SDK to percy-capybara@^5.0.0? Yes
|
84
|
+
? The Capybara API has breaking changes, automatically convert to the new API? Yes
|
85
|
+
```
|
86
|
+
|
87
|
+
This will automatically run the changes described below for you, with the
|
88
|
+
exception of changing the `require`.
|
89
|
+
|
73
90
|
### Manually
|
74
91
|
|
75
92
|
#### Require change
|
@@ -78,6 +95,25 @@ The name of the require has changed from `require 'percy'` to `require
|
|
78
95
|
'percy/capybara'`. This is to avoid conflict with our [Ruby Selenium SDK's](https://github.com/percy/percy-selenium-ruby)
|
79
96
|
require statement.
|
80
97
|
|
98
|
+
#### API change
|
99
|
+
|
100
|
+
The previous version of this SDK had the following function signature:
|
101
|
+
|
102
|
+
``` ruby
|
103
|
+
Percy.snapshot(driver, name, options)
|
104
|
+
```
|
105
|
+
|
106
|
+
v5.x of this SDK has a significant change to the API. There no longer is a stand
|
107
|
+
alone module to call and you no longer need to pass the page/driver. It's
|
108
|
+
available on the current Capybara session (`page`):
|
109
|
+
|
110
|
+
``` ruby
|
111
|
+
page.percy_snapshot(name, options)
|
112
|
+
```
|
113
|
+
|
114
|
+
If you were using this SDK outside of Capybara, you'll likely find the [Ruby
|
115
|
+
Selenium SDK a better fit](https://github.com/percy/percy-selenium-ruby)
|
116
|
+
|
81
117
|
#### Installing `@percy/cli` & removing `@percy/agent`
|
82
118
|
|
83
119
|
If you're coming from a 4.x version of this package, make sure to install `@percy/cli` after
|
data/lib/percy/capybara.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
3
|
require 'capybara/dsl'
|
4
|
+
require_relative './version'
|
4
5
|
|
5
6
|
module PercyCapybara
|
6
|
-
include Capybara::DSL
|
7
|
-
|
8
7
|
CLIENT_INFO = "percy-capybara/#{VERSION}".freeze
|
9
8
|
ENV_INFO = "capybara/#{Capybara::VERSION} ruby/#{RUBY_VERSION}".freeze
|
10
9
|
|
@@ -19,17 +18,20 @@ module PercyCapybara
|
|
19
18
|
def percy_snapshot(name, options = {})
|
20
19
|
return unless percy_enabled?
|
21
20
|
|
21
|
+
page = Capybara.current_session
|
22
|
+
|
22
23
|
begin
|
23
24
|
page.evaluate_script(fetch_percy_dom)
|
24
|
-
dom_snapshot =
|
25
|
-
|
25
|
+
dom_snapshot = page
|
26
|
+
.evaluate_script("(function() { return PercyDOM.serialize(#{options.to_json}) })()")
|
26
27
|
|
27
28
|
response = fetch('percy/snapshot',
|
28
29
|
name: name,
|
29
30
|
url: page.current_url,
|
30
31
|
dom_snapshot: dom_snapshot,
|
31
32
|
client_info: CLIENT_INFO,
|
32
|
-
environment_info: ENV_INFO,
|
33
|
+
environment_info: ENV_INFO,
|
34
|
+
**options,)
|
33
35
|
|
34
36
|
unless response.body.to_json['success']
|
35
37
|
raise StandardError, data['error']
|
data/lib/percy/version.rb
CHANGED
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: 5.0.0
|
4
|
+
version: 5.0.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: 2021-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -115,28 +115,10 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".github/dependabot.yml"
|
119
|
-
- ".github/release-drafter.yml"
|
120
|
-
- ".github/workflows/changelog.yml"
|
121
|
-
- ".github/workflows/lint.yml"
|
122
|
-
- ".github/workflows/release.yml"
|
123
|
-
- ".github/workflows/test.yml"
|
124
|
-
- ".gitignore"
|
125
|
-
- ".rspec"
|
126
|
-
- ".rubocop.yml"
|
127
|
-
- ".yardopts"
|
128
|
-
- Gemfile
|
129
|
-
- Guardfile
|
130
118
|
- LICENSE
|
131
|
-
- Makefile
|
132
119
|
- README.md
|
133
|
-
- Rakefile
|
134
120
|
- lib/percy/capybara.rb
|
135
121
|
- lib/percy/version.rb
|
136
|
-
- percy-capybara.gemspec
|
137
|
-
- spec/fixture/index.html
|
138
|
-
- spec/lib/percy/percy_capybara_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
140
122
|
homepage: ''
|
141
123
|
licenses:
|
142
124
|
- MIT
|
@@ -154,15 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
136
|
version: 2.3.0
|
155
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
138
|
requirements:
|
157
|
-
- - "
|
139
|
+
- - ">="
|
158
140
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
141
|
+
version: '0'
|
160
142
|
requirements: []
|
161
143
|
rubygems_version: 3.0.3
|
162
144
|
signing_key:
|
163
145
|
specification_version: 4
|
164
146
|
summary: Percy visual testing for Capybara
|
165
|
-
test_files:
|
166
|
-
- spec/fixture/index.html
|
167
|
-
- spec/lib/percy/percy_capybara_spec.rb
|
168
|
-
- spec/spec_helper.rb
|
147
|
+
test_files: []
|
data/.github/dependabot.yml
DELETED
data/.github/release-drafter.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
name-template: 'v$RESOLVED_VERSION'
|
2
|
-
tag-template: 'v$RESOLVED_VERSION'
|
3
|
-
categories:
|
4
|
-
- title: '💥 Breaking Changes'
|
5
|
-
labels:
|
6
|
-
- breaking
|
7
|
-
- title: '✨ Enhancements'
|
8
|
-
labels:
|
9
|
-
- feature
|
10
|
-
- enhancement
|
11
|
-
- title: '🐛 Bug Fixes'
|
12
|
-
labels:
|
13
|
-
- fix
|
14
|
-
- bugfix
|
15
|
-
- bug
|
16
|
-
- title: '🏗 Maintenance'
|
17
|
-
labels:
|
18
|
-
- chore
|
19
|
-
- dependencies
|
20
|
-
change-title-escapes: '\<*_&#@'
|
21
|
-
version-resolver:
|
22
|
-
major:
|
23
|
-
labels:
|
24
|
-
- breaking
|
25
|
-
minor:
|
26
|
-
labels:
|
27
|
-
- feature
|
28
|
-
- enhancement
|
29
|
-
default: patch
|
30
|
-
template: '$CHANGES'
|
31
|
-
prerelease: true
|
data/.github/workflows/lint.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
name: Lint
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [master]
|
5
|
-
pull_request:
|
6
|
-
workflow_dispatch:
|
7
|
-
jobs:
|
8
|
-
lint:
|
9
|
-
name: Lint
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
steps:
|
12
|
-
- uses: actions/checkout@v2
|
13
|
-
- uses: ruby/setup-ruby@v1
|
14
|
-
with:
|
15
|
-
ruby-version: 2.6
|
16
|
-
bundler-cache: true
|
17
|
-
- uses: actions/cache@v2
|
18
|
-
with:
|
19
|
-
path: "./vendor/bundle"
|
20
|
-
key: v1/${{ runner.os }}/ruby-2.6/${{ hashFiles('**/Gemfile.lock') }}
|
21
|
-
restore-keys: v1/${{ runner.os }}/ruby-2.6/
|
22
|
-
- run: bundle exec rubocop
|
@@ -1,22 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
on:
|
3
|
-
release:
|
4
|
-
types: [published]
|
5
|
-
jobs:
|
6
|
-
publish:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
steps:
|
9
|
-
- uses: actions/checkout@v2
|
10
|
-
- uses: ruby/setup-ruby@v1
|
11
|
-
with:
|
12
|
-
ruby-version: 2.6
|
13
|
-
bundler-cache: true
|
14
|
-
- uses: actions/cache@v2
|
15
|
-
with:
|
16
|
-
path: "./vendor/bundle"
|
17
|
-
key: v1/${{ runner.os }}/ruby-2.6/${{ hashFiles('**/Gemfile.lock') }}
|
18
|
-
restore-keys: v1/${{ runner.os }}/ruby-2.6/
|
19
|
-
- uses: cadwallion/publish-rubygems-action@master
|
20
|
-
env:
|
21
|
-
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
22
|
-
RELEASE_COMMAND: make release
|
data/.github/workflows/test.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
name: Test
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [master]
|
5
|
-
pull_request:
|
6
|
-
workflow_dispatch:
|
7
|
-
jobs:
|
8
|
-
test:
|
9
|
-
name: Test
|
10
|
-
strategy:
|
11
|
-
matrix:
|
12
|
-
os: [ubuntu-latest]
|
13
|
-
ruby: ['2.6', '2.7']
|
14
|
-
runs-on: ${{ matrix.os }}
|
15
|
-
steps:
|
16
|
-
- uses: actions/checkout@v2
|
17
|
-
- uses: ruby/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{matrix.ruby}}
|
20
|
-
bundler-cache: true
|
21
|
-
- uses: actions/cache@v2
|
22
|
-
with:
|
23
|
-
path: "./vendor/bundle"
|
24
|
-
key: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/${{ hashFiles('**/Gemfile.lock') }}
|
25
|
-
restore-keys: v1/${{ runner.os }}/ruby-${{ matrix.ruby }}/
|
26
|
-
- run: bundle exec rspec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.yardopts
DELETED
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in percy-capybara.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'guard-rspec', require: false
|
7
|
-
|
8
|
-
# (for development)
|
9
|
-
# gem 'percy-client', path: '~/src/percy-client'
|
10
|
-
|
11
|
-
group :test, :development do
|
12
|
-
gem 'pry'
|
13
|
-
gem 'puma'
|
14
|
-
gem 'webmock'
|
15
|
-
gem 'simplecov', require: false
|
16
|
-
end
|
data/Guardfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
2
|
-
require 'guard/rspec/dsl'
|
3
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
-
|
5
|
-
# RSpec files
|
6
|
-
rspec = dsl.rspec
|
7
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
-
watch(rspec.spec_files)
|
10
|
-
|
11
|
-
# Ruby files
|
12
|
-
ruby = dsl.ruby
|
13
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
-
end
|
data/Makefile
DELETED
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
data/percy-capybara.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative './lib/percy/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'percy-capybara'
|
5
|
-
spec.version = PercyCapybara::VERSION
|
6
|
-
spec.authors = ['Perceptual Inc.']
|
7
|
-
spec.email = ['team@percy.io']
|
8
|
-
spec.summary = %q{Percy visual testing for Capybara}
|
9
|
-
spec.description = %q{}
|
10
|
-
spec.homepage = ''
|
11
|
-
spec.license = 'MIT'
|
12
|
-
spec.required_ruby_version = '>= 2.3.0'
|
13
|
-
|
14
|
-
spec.metadata = {
|
15
|
-
'bug_tracker_uri' => 'https://github.com/percy/percy-capybara/issues',
|
16
|
-
'source_code_uri' => 'https://github.com/percy/percy-capybara',
|
17
|
-
}
|
18
|
-
|
19
|
-
spec.files = `git ls-files -z`.split("\x0")
|
20
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
-
spec.require_paths = ['lib']
|
23
|
-
|
24
|
-
spec.add_runtime_dependency 'capybara', '>= 3'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'selenium-webdriver', '>= 4.0.0.beta1'
|
27
|
-
spec.add_development_dependency 'bundler', '>= 2.0'
|
28
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.5'
|
30
|
-
spec.add_development_dependency 'capybara', '~> 3.31'
|
31
|
-
spec.add_development_dependency 'percy-style', '~> 0.7.0'
|
32
|
-
end
|
data/spec/fixture/index.html
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<html><head><title>I am a page</title></head><body>Snapshot me</body></html>
|
@@ -1,103 +0,0 @@
|
|
1
|
-
LABEL = PercyCapybara::PERCY_LABEL
|
2
|
-
|
3
|
-
RSpec.describe PercyCapybara, type: :feature do
|
4
|
-
before(:each) do
|
5
|
-
WebMock.disable_net_connect!(allow: '127.0.0.1', disallow: 'localhost')
|
6
|
-
page.__percy_clear_cache!
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'snapshot', type: :feature do
|
10
|
-
it 'disables when healthcheck version is incorrect' do
|
11
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
12
|
-
.to_return(status: 200, body: '', headers: {'x-percy-core-version': '0.1.0'})
|
13
|
-
|
14
|
-
expect { page.percy_snapshot('Name') }
|
15
|
-
.to output("#{LABEL} Unsupported Percy CLI version, 0.1.0\n").to_stdout
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'disables when healthcheck version is missing' do
|
19
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
20
|
-
.to_return(status: 200, body: '', headers: {})
|
21
|
-
|
22
|
-
expect { page.percy_snapshot('Name') }
|
23
|
-
.to output(
|
24
|
-
"#{LABEL} You may be using @percy/agent which" \
|
25
|
-
' is no longer supported by this SDK. Please uninstall' \
|
26
|
-
' @percy/agent and install @percy/cli instead.' \
|
27
|
-
" https://docs.percy.io/docs/migrating-to-percy-cli\n",
|
28
|
-
).to_stdout
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'disables when healthcheck fails' do
|
32
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
33
|
-
.to_return(status: 500, body: '', headers: {})
|
34
|
-
|
35
|
-
expect { page.percy_snapshot('Name') }
|
36
|
-
.to output("#{LABEL} Percy is not running, disabling snapshots\n").to_stdout
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'disables when healthcheck fails to connect' do
|
40
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
41
|
-
.to_raise(StandardError)
|
42
|
-
|
43
|
-
expect { page.percy_snapshot('Name') }
|
44
|
-
.to output("#{LABEL} Percy is not running, disabling snapshots\n").to_stdout
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'throws an error when name is not provided' do
|
48
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
49
|
-
.to_return(status: 500, body: '', headers: {})
|
50
|
-
|
51
|
-
expect { page.percy_snapshot }.to raise_error(ArgumentError)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'logs an error when sending a snapshot fails' do
|
55
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
56
|
-
.to_return(status: 200, body: '', headers: {'x-percy-core-version': '1.0.0'})
|
57
|
-
|
58
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/dom.js")
|
59
|
-
.to_return(
|
60
|
-
status: 200,
|
61
|
-
body: 'window.PercyDOM = { serialize: () => document.documentElement.outerHTML };',
|
62
|
-
headers: {},
|
63
|
-
)
|
64
|
-
|
65
|
-
stub_request(:post, 'http://localhost:5338/percy/snapshot')
|
66
|
-
.to_return(status: 200, body: '', headers: {})
|
67
|
-
|
68
|
-
expect { page.percy_snapshot('Name') }
|
69
|
-
.to output("#{LABEL} Could not take DOM snapshot 'Name'\n").to_stdout
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'sends snapshots to the local server' do
|
73
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/healthcheck")
|
74
|
-
.to_return(status: 200, body: '', headers: {'x-percy-core-version': '1.0.0'})
|
75
|
-
|
76
|
-
stub_request(:get, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/dom.js")
|
77
|
-
.to_return(
|
78
|
-
status: 200,
|
79
|
-
body: 'window.PercyDOM = { serialize: () => document.documentElement.outerHTML };',
|
80
|
-
headers: {},
|
81
|
-
)
|
82
|
-
|
83
|
-
stub_request(:post, 'http://localhost:5338/percy/snapshot')
|
84
|
-
.to_return(status: 200, body: '{"success": "true" }', headers: {})
|
85
|
-
|
86
|
-
visit 'index.html'
|
87
|
-
page.percy_snapshot('Name')
|
88
|
-
|
89
|
-
expect(WebMock)
|
90
|
-
.to have_requested(:post, "#{PercyCapybara::PERCY_SERVER_ADDRESS}/percy/snapshot")
|
91
|
-
.with(
|
92
|
-
body: {
|
93
|
-
name: 'Name',
|
94
|
-
url: 'http://127.0.0.1:3003/index.html',
|
95
|
-
dom_snapshot:
|
96
|
-
"<html><head><title>I am a page</title></head><body>Snapshot me\n</body></html>",
|
97
|
-
client_info: "percy-capybara/#{PercyCapybara::VERSION}",
|
98
|
-
environment_info: "capybara/#{Capybara::VERSION} ruby/#{RUBY_VERSION}",
|
99
|
-
}.to_json,
|
100
|
-
).once
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# This must be required & started before any app code (for proper coverage)
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
SimpleCov.minimum_coverage 100
|
5
|
-
|
6
|
-
require 'capybara/rspec'
|
7
|
-
require 'webmock/rspec'
|
8
|
-
require 'percy/capybara'
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.expect_with :rspec do |expectations|
|
12
|
-
# This option will default to `true` in RSpec 4.
|
13
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
14
|
-
end
|
15
|
-
|
16
|
-
config.mock_with :rspec do |mocks|
|
17
|
-
mocks.verify_partial_doubles = true
|
18
|
-
end
|
19
|
-
|
20
|
-
config.disable_monkey_patching!
|
21
|
-
# config.warnings = true
|
22
|
-
|
23
|
-
# Run specs in random order to surface order dependencies. If you find an
|
24
|
-
# order dependency and want to debug it, you can fix the order by providing
|
25
|
-
# the seed, which is printed after each run.
|
26
|
-
# --seed 1234
|
27
|
-
config.order = :random
|
28
|
-
|
29
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
30
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
31
|
-
# test failures related to randomization by passing the same `--seed` value
|
32
|
-
# as the one that triggered the failure.
|
33
|
-
Kernel.srand config.seed
|
34
|
-
|
35
|
-
# See https://github.com/teamcapybara/capybara#selecting-the-driver for other options
|
36
|
-
Capybara.default_driver = :selenium_headless
|
37
|
-
Capybara.javascript_driver = :selenium_headless
|
38
|
-
|
39
|
-
# Setup for Capybara to test static files served by Rack
|
40
|
-
Capybara.server_port = 3003
|
41
|
-
Capybara.server = :puma, { Silent: true }
|
42
|
-
Capybara.app = Rack::File.new(File.join(File.dirname(__FILE__), 'fixture'))
|
43
|
-
end
|
44
|
-
|
45
|
-
## Add cache clearing methods for tests
|
46
|
-
Capybara::Session.class_eval {
|
47
|
-
def __percy_clear_cache!
|
48
|
-
@percy_dom = nil
|
49
|
-
@percy_enabled = nil
|
50
|
-
end
|
51
|
-
}
|