percy-cli 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +60 -26
- data/Gemfile +4 -0
- data/RELEASING.md +17 -0
- data/lib/percy/cli.rb +5 -3
- data/lib/percy/cli/{snapshot.rb → snapshot_runner.rb} +53 -36
- data/lib/percy/cli/version.rb +1 -1
- data/spec/percy/cli/{snapshot_spec.rb → snapshot_runner_spec.rb} +62 -39
- data/spec/percy/cli/testdata/images/jellybeans-symlink.png +0 -0
- data/spec/percy/cli/testdata/subdir/test_symlink.html +1 -0
- metadata +7 -10
- data/spec/percy/cli/testdata/images/jellybeans-symlink.png +0 -1
- data/spec/percy/cli/testdata/images_symlink +0 -1
- data/spec/percy/cli/testdata/subdir/test_symlink.html +0 -1
- data/spec/percy/cli/testdata/subdir_symlink +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64b4abeaf29cbbe7f5a90c445b034795fa4a3978
|
4
|
+
data.tar.gz: d65287197152cbf4d476408895a78b8d62ebcb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6f264c90ad78f351975f261ab98e68e4257e7277a0e9ea1e4637f5d3e2bfc29d8f3c5ee4ac797434b9c9a4f5f2736aa26df68983ef1e9479d7113649abcb4d9
|
7
|
+
data.tar.gz: faeceecd9a612cfeb66a8d88dc1573d4125c322260c54fa9254d809c9d005aa7b20508a5878582b5d72fee1dfd9bd9b88dc35b030f3e74aace1805cd0a74a64b
|
data/.rubocop.yml
CHANGED
@@ -8,44 +8,66 @@ AllCops:
|
|
8
8
|
- 'vendor/**/*'
|
9
9
|
- '*.gemspec'
|
10
10
|
|
11
|
+
Layout/AlignParameters:
|
12
|
+
EnforcedStyle: with_fixed_indentation
|
13
|
+
|
14
|
+
Layout/CaseIndentation:
|
15
|
+
EnforcedStyle: end
|
16
|
+
|
17
|
+
Layout/IndentArray:
|
18
|
+
EnforcedStyle: consistent
|
19
|
+
|
20
|
+
Layout/MultilineMethodCallIndentation:
|
21
|
+
EnforcedStyle: indented
|
22
|
+
|
23
|
+
Layout/MultilineOperationIndentation:
|
24
|
+
EnforcedStyle: indented
|
25
|
+
|
26
|
+
Layout/SpaceInsideHashLiteralBraces:
|
27
|
+
EnforcedStyle: no_space
|
28
|
+
|
11
29
|
Lint/EndAlignment:
|
12
30
|
EnforcedStyleAlignWith: variable
|
13
31
|
|
14
|
-
|
15
|
-
|
32
|
+
Lint/RescueException:
|
33
|
+
Exclude:
|
34
|
+
- 'lib/tasks/*.rake'
|
16
35
|
|
17
|
-
Metrics/
|
18
|
-
|
36
|
+
Metrics/AbcSize:
|
37
|
+
Max: 100
|
19
38
|
|
20
|
-
|
21
|
-
|
39
|
+
Metrics/LineLength:
|
40
|
+
Max: 100
|
22
41
|
|
23
|
-
|
24
|
-
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 80
|
25
44
|
|
26
45
|
Style/Documentation:
|
27
46
|
Enabled: false
|
28
47
|
|
29
|
-
|
48
|
+
Metrics/ClassLength:
|
30
49
|
Enabled: false
|
31
50
|
|
32
|
-
|
33
|
-
|
51
|
+
Metrics/ModuleLength:
|
52
|
+
Enabled: false
|
34
53
|
|
35
|
-
|
36
|
-
|
54
|
+
Metrics/ParameterLists:
|
55
|
+
Enabled: false
|
37
56
|
|
38
|
-
|
39
|
-
|
57
|
+
Metrics/BlockLength:
|
58
|
+
Enabled: false
|
40
59
|
|
41
|
-
|
42
|
-
Style/NumericLiterals:
|
60
|
+
Style/DoubleNegation:
|
43
61
|
Enabled: false
|
44
62
|
|
45
63
|
Style/FileName:
|
46
|
-
|
64
|
+
Exclude: ['Gemfile', 'Guardfile']
|
47
65
|
|
48
|
-
Style/
|
66
|
+
Style/FormatStringToken:
|
67
|
+
EnforcedStyle: template
|
68
|
+
|
69
|
+
# Disable Style/NumericLiterals so numbers don't need underscores
|
70
|
+
Style/NumericLiterals:
|
49
71
|
Enabled: false
|
50
72
|
|
51
73
|
Style/NumericPredicate:
|
@@ -57,9 +79,11 @@ Style/RedundantBegin:
|
|
57
79
|
Style/RegexpLiteral:
|
58
80
|
EnforcedStyle: slashes
|
59
81
|
AllowInnerSlashes: true
|
82
|
+
Exclude:
|
83
|
+
- 'Guardfile'
|
60
84
|
|
61
|
-
Style/
|
62
|
-
EnforcedStyle:
|
85
|
+
Style/SymbolArray:
|
86
|
+
EnforcedStyle: brackets
|
63
87
|
|
64
88
|
Style/TrailingCommaInArguments:
|
65
89
|
EnforcedStyleForMultiline: consistent_comma
|
@@ -67,13 +91,23 @@ Style/TrailingCommaInArguments:
|
|
67
91
|
Style/TrailingCommaInLiteral:
|
68
92
|
EnforcedStyleForMultiline: consistent_comma
|
69
93
|
|
94
|
+
RSpec/DescribedClass:
|
95
|
+
EnforcedStyle: explicit
|
96
|
+
|
97
|
+
RSpec/ExampleLength:
|
98
|
+
Max: 15
|
99
|
+
|
100
|
+
RSpec/HookArgument:
|
101
|
+
EnforcedStyle: each
|
102
|
+
|
103
|
+
RSpec/ImplicitExpect:
|
104
|
+
EnforcedStyle: should
|
105
|
+
|
70
106
|
RSpec/MessageSpies:
|
71
107
|
EnforcedStyle: receive
|
72
108
|
|
73
109
|
RSpec/NotToNot:
|
74
|
-
|
75
|
-
|
110
|
+
EnforcedStyle: to_not
|
76
111
|
|
77
|
-
|
78
|
-
|
79
|
-
# EnforcedStyle: explicit
|
112
|
+
RSpec/VerifiedDoubles:
|
113
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/RELEASING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Releasing
|
2
|
+
|
3
|
+
1. Update version.rb file accordingly.
|
4
|
+
1. Tag the release: `git tag vVERSION`
|
5
|
+
1. Push changes: `git push --tags`
|
6
|
+
1. Ensure tests have passed on that tag
|
7
|
+
1. [Update the release notes](https://github.com/percy/percy-cli/releases) on GitHub
|
8
|
+
1. Build and publish:
|
9
|
+
|
10
|
+
```bash
|
11
|
+
bundle exec rake build
|
12
|
+
gem push pkg/percy-cli-X.XX.XX.gem
|
13
|
+
```
|
14
|
+
|
15
|
+
* Announce the new release,
|
16
|
+
making sure to say "thank you" to the contributors
|
17
|
+
who helped shape this version!
|
data/lib/percy/cli.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'commander'
|
2
2
|
require 'percy'
|
3
3
|
require 'percy/cli/version'
|
4
|
-
require 'percy/cli/
|
4
|
+
require 'percy/cli/snapshot_runner'
|
5
5
|
|
6
6
|
module Percy
|
7
7
|
class Cli
|
8
8
|
include Commander::Methods
|
9
|
-
include Percy::Cli::Snapshot
|
10
9
|
|
11
10
|
DEFAULT_NUM_THREADS = 3
|
12
11
|
MAX_NUM_THREADS = 10
|
@@ -76,12 +75,15 @@ module Percy
|
|
76
75
|
options.widths = (options.widths || '').split(',')
|
77
76
|
|
78
77
|
raise OptionParser::MissingArgument, 'root folder path is required' if args.empty?
|
78
|
+
|
79
79
|
if args.length > 1
|
80
80
|
raise OptionParser::MissingArgument, 'only a single root folder path can be given'
|
81
81
|
end
|
82
|
+
|
82
83
|
root_dir = args.first
|
83
84
|
|
84
|
-
|
85
|
+
snapshot_runner = Percy::Cli::SnapshotRunner.new
|
86
|
+
snapshot_runner.run(root_dir, options.__hash__)
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -8,7 +8,9 @@ Thread::Pool.abort_on_exception = true
|
|
8
8
|
|
9
9
|
module Percy
|
10
10
|
class Cli
|
11
|
-
|
11
|
+
class SnapshotRunner
|
12
|
+
attr_reader :client
|
13
|
+
|
12
14
|
# Static resource types that an HTML file might load and that we want to upload for rendering.
|
13
15
|
STATIC_RESOURCE_EXTENSIONS = [
|
14
16
|
'.css', '.js', '.jpg', '.jpeg', '.gif', '.ico', '.png', '.bmp', '.pict', '.tif', '.tiff',
|
@@ -18,7 +20,11 @@ module Percy
|
|
18
20
|
DEFAULT_SNAPSHOTS_REGEX = /\.(html|htm)$/
|
19
21
|
MAX_FILESIZE_BYTES = 15 * 1024**2 # 15 MB.
|
20
22
|
|
21
|
-
def
|
23
|
+
def initialize
|
24
|
+
@client = Percy::Client.new(client_info: "percy-cli/#{VERSION}", environment_info: '')
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(root_dir, options = {})
|
22
28
|
repo = options[:repo] || Percy.config.repo
|
23
29
|
root_dir = File.expand_path(File.absolute_path(root_dir))
|
24
30
|
strip_prefix = File.expand_path(File.absolute_path(options[:strip_prefix] || root_dir))
|
@@ -33,10 +39,10 @@ module Percy
|
|
33
39
|
base_resource_options = {strip_prefix: strip_prefix, baseurl: baseurl}
|
34
40
|
|
35
41
|
# Find all the static files in the given root directory.
|
36
|
-
root_paths =
|
37
|
-
resource_paths =
|
38
|
-
root_resources =
|
39
|
-
build_resources =
|
42
|
+
root_paths = _find_root_paths(root_dir, snapshots_regex: options[:snapshots_regex])
|
43
|
+
resource_paths = _find_resource_paths(root_dir, include_all: include_all)
|
44
|
+
root_resources = _list_resources(root_paths, base_resource_options.merge(is_root: true))
|
45
|
+
build_resources = _list_resources(resource_paths, base_resource_options)
|
40
46
|
all_resources = root_resources + build_resources
|
41
47
|
|
42
48
|
if root_resources.empty?
|
@@ -48,57 +54,62 @@ module Percy
|
|
48
54
|
Percy.logger.debug { "Found build resource: #{resource.resource_url}" }
|
49
55
|
end
|
50
56
|
|
51
|
-
build =
|
57
|
+
build = _rescue_connection_failures do
|
52
58
|
say 'Creating build...'
|
53
|
-
|
59
|
+
|
60
|
+
build = client.create_build(repo, resources: build_resources)
|
54
61
|
|
55
62
|
say 'Uploading build resources...'
|
56
|
-
|
63
|
+
_upload_missing_resources(build, build, all_resources, num_threads: num_threads)
|
57
64
|
|
58
65
|
build
|
59
66
|
end
|
60
|
-
return if
|
67
|
+
return if _failed?
|
61
68
|
|
62
69
|
# Upload a snapshot for every root resource, and associate the build_resources.
|
63
70
|
output_lock = Mutex.new
|
64
71
|
snapshot_thread_pool = Thread.pool(num_threads)
|
65
72
|
total = snapshot_limit ? [root_resources.length, snapshot_limit].min : root_resources.length
|
73
|
+
|
66
74
|
root_resources.each_with_index do |root_resource, i|
|
67
75
|
break if snapshot_limit && i + 1 > snapshot_limit
|
76
|
+
|
68
77
|
snapshot_thread_pool.process do
|
69
78
|
output_lock.synchronize do
|
70
79
|
say "Uploading snapshot (#{i + 1}/#{total}): #{root_resource.resource_url}"
|
71
80
|
end
|
72
|
-
|
73
|
-
|
81
|
+
|
82
|
+
_rescue_connection_failures do
|
83
|
+
snapshot = client.create_snapshot(
|
74
84
|
build['data']['id'],
|
75
85
|
[root_resource],
|
76
86
|
enable_javascript: enable_javascript,
|
77
87
|
widths: widths,
|
78
88
|
)
|
79
|
-
|
80
|
-
|
89
|
+
_upload_missing_resources(build, snapshot, all_resources, num_threads: num_threads)
|
90
|
+
client.finalize_snapshot(snapshot['data']['id'])
|
81
91
|
end
|
82
92
|
end
|
83
93
|
end
|
94
|
+
|
84
95
|
snapshot_thread_pool.wait
|
85
96
|
snapshot_thread_pool.shutdown
|
86
97
|
|
87
98
|
# Finalize the build.
|
88
99
|
say 'Finalizing build...'
|
89
|
-
|
90
|
-
|
100
|
+
_rescue_connection_failures { client.finalize_build(build['data']['id']) }
|
101
|
+
|
102
|
+
return if _failed?
|
103
|
+
|
91
104
|
say 'Done! Percy is now processing, you can view the visual diffs here:'
|
92
105
|
say build['data']['attributes']['web-url']
|
93
106
|
end
|
94
107
|
|
95
|
-
|
96
|
-
|
97
|
-
def failed?
|
108
|
+
def _failed?
|
98
109
|
!!@failed
|
99
110
|
end
|
100
111
|
|
101
|
-
def
|
112
|
+
def _rescue_connection_failures
|
102
113
|
raise ArgumentError, 'block is requried' unless block_given?
|
103
114
|
begin
|
104
115
|
yield
|
@@ -108,25 +119,22 @@ module Percy
|
|
108
119
|
Percy::Client::ConflictError, # Rescue project disabled errors and others.
|
109
120
|
Percy::Client::ConnectionFailed, # Rescue some networking errors.
|
110
121
|
Percy::Client::TimeoutError => e
|
122
|
+
|
111
123
|
Percy.logger.error(e)
|
112
124
|
@failed = true
|
113
125
|
nil
|
114
126
|
end
|
115
127
|
end
|
116
128
|
|
117
|
-
def
|
118
|
-
|
129
|
+
def _find_root_paths(dir_path, options = {})
|
130
|
+
_find_files(dir_path).select { |path| _include_root_path?(path, options) }
|
119
131
|
end
|
120
132
|
|
121
|
-
def
|
122
|
-
|
133
|
+
def _find_resource_paths(dir_path, options = {})
|
134
|
+
_find_files(dir_path).select { |path| _include_resource_path?(path, options) }
|
123
135
|
end
|
124
136
|
|
125
|
-
def
|
126
|
-
url[0..1] == '//' ? "http:#{url}" : url
|
127
|
-
end
|
128
|
-
|
129
|
-
def list_resources(paths, options = {})
|
137
|
+
def _list_resources(paths, options = {})
|
130
138
|
strip_prefix = File.expand_path(options[:strip_prefix])
|
131
139
|
baseurl = options[:baseurl]
|
132
140
|
resources = []
|
@@ -147,9 +155,10 @@ module Percy
|
|
147
155
|
end
|
148
156
|
|
149
157
|
# Uploads missing resources either for a build or snapshot.
|
150
|
-
def
|
158
|
+
def _upload_missing_resources(build, obj, potential_resources, options = {})
|
151
159
|
# Upload the content for any missing resources.
|
152
160
|
missing_resources = obj['data']['relationships']['missing-resources']['data']
|
161
|
+
|
153
162
|
bar = Commander::UI::ProgressBar.new(
|
154
163
|
missing_resources.length,
|
155
164
|
title: 'Uploading resources...',
|
@@ -157,12 +166,15 @@ module Percy
|
|
157
166
|
width: 20,
|
158
167
|
complete_message: nil,
|
159
168
|
)
|
169
|
+
|
160
170
|
output_lock = Mutex.new
|
161
171
|
uploader_thread_pool = Thread.pool(options[:num_threads] || 10)
|
172
|
+
|
162
173
|
missing_resources.each do |missing_resource|
|
163
174
|
uploader_thread_pool.process do
|
164
175
|
missing_resource_sha = missing_resource['id']
|
165
176
|
resource = potential_resources.find { |r| r.sha == missing_resource_sha }
|
177
|
+
|
166
178
|
output_lock.synchronize do
|
167
179
|
bar.increment resource_url: resource.resource_url
|
168
180
|
end
|
@@ -171,34 +183,39 @@ module Percy
|
|
171
183
|
# read from the filesystem.
|
172
184
|
content = resource.content || File.read(resource.path.to_s)
|
173
185
|
|
174
|
-
|
186
|
+
client.upload_resource(build['data']['id'], content)
|
175
187
|
end
|
176
188
|
end
|
189
|
+
|
177
190
|
uploader_thread_pool.wait
|
178
191
|
uploader_thread_pool.shutdown
|
179
192
|
end
|
180
193
|
|
181
194
|
# A file find method that follows directory and file symlinks.
|
182
|
-
def
|
195
|
+
def _find_files(*paths)
|
183
196
|
paths.flatten!
|
184
197
|
paths.map! { |p| Pathname.new(p) }
|
185
198
|
files = paths.select(&:file?)
|
199
|
+
|
186
200
|
(paths - files).each do |dir|
|
187
|
-
files <<
|
201
|
+
files << _find_files(dir.children)
|
188
202
|
end
|
203
|
+
|
189
204
|
files.flatten.map(&:to_s)
|
190
205
|
end
|
191
206
|
|
192
|
-
def
|
207
|
+
def _include_resource_path?(path, options)
|
193
208
|
# Skip git files.
|
194
209
|
return false if path =~ /\/\.git\//
|
195
210
|
return true if options[:include_all]
|
196
|
-
|
211
|
+
|
212
|
+
STATIC_RESOURCE_EXTENSIONS.include?(File.extname(path))
|
197
213
|
end
|
198
214
|
|
199
|
-
def
|
215
|
+
def _include_root_path?(path, options)
|
200
216
|
# Skip git files.
|
201
217
|
return false if path =~ /\/\.git\//
|
218
|
+
|
202
219
|
# Skip files that don't match the snapshots_regex.
|
203
220
|
snapshots_regex = options[:snapshots_regex] || DEFAULT_SNAPSHOTS_REGEX
|
204
221
|
path.match(snapshots_regex)
|
data/lib/percy/cli/version.rb
CHANGED
@@ -1,68 +1,83 @@
|
|
1
1
|
require 'digest'
|
2
2
|
|
3
|
-
RSpec.describe Percy::Cli::
|
3
|
+
RSpec.describe Percy::Cli::SnapshotRunner do
|
4
|
+
subject(:runner) { Percy::Cli::SnapshotRunner.new }
|
5
|
+
|
4
6
|
let(:root_dir) { File.expand_path('../testdata/', __FILE__) }
|
5
7
|
|
6
8
|
# Used for testing that paths are collapsed before use.r
|
7
9
|
let(:root_dir_relative) { root_dir + '/../testdata' }
|
8
10
|
|
9
|
-
describe '#
|
11
|
+
describe '#initialize' do
|
12
|
+
it 'passes client info down to the lower level Percy client' do
|
13
|
+
expect(runner.client.client_info).to eq("percy-cli/#{Percy::Cli::VERSION}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#run' do
|
10
18
|
xit 'snapshots a root directory of static files' do
|
11
19
|
# TODO(fotinakis): tests for the full flow.
|
12
20
|
end
|
13
21
|
end
|
14
|
-
describe '#rescue_connection_failures' do
|
15
|
-
let(:cli) { Percy::Cli.new }
|
16
22
|
|
23
|
+
describe '#rescue_connection_failures' do
|
17
24
|
it 'returns block result on success' do
|
18
|
-
result =
|
19
|
-
|
20
|
-
|
21
|
-
expect(
|
22
|
-
expect(cli.send(:failed?)).to eq(false)
|
25
|
+
result = runner._rescue_connection_failures { true }
|
26
|
+
|
27
|
+
expect(result).to be true
|
28
|
+
expect(runner._failed?).to be false
|
23
29
|
end
|
30
|
+
|
24
31
|
it 'makes block safe from quota exceeded errors' do
|
25
|
-
result =
|
32
|
+
result = runner._rescue_connection_failures do
|
26
33
|
raise Percy::Client::PaymentRequiredError.new(409, 'POST', '', '')
|
27
34
|
end
|
28
|
-
|
29
|
-
expect(
|
35
|
+
|
36
|
+
expect(result).to be_nil
|
37
|
+
expect(runner._failed?).to be true
|
30
38
|
end
|
39
|
+
|
31
40
|
it 'makes block safe from server errors' do
|
32
|
-
result =
|
41
|
+
result = runner._rescue_connection_failures do
|
33
42
|
raise Percy::Client::ServerError.new(502, 'POST', '', '')
|
34
43
|
end
|
35
|
-
|
36
|
-
expect(
|
44
|
+
|
45
|
+
expect(result).to be_nil
|
46
|
+
expect(runner._failed?).to be true
|
37
47
|
end
|
48
|
+
|
38
49
|
it 'makes block safe from ConnectionFailed' do
|
39
|
-
result =
|
40
|
-
|
41
|
-
|
42
|
-
expect(
|
43
|
-
expect(cli.send(:failed?)).to eq(true)
|
50
|
+
result = runner._rescue_connection_failures { raise Percy::Client::ConnectionFailed }
|
51
|
+
|
52
|
+
expect(result).to be_nil
|
53
|
+
expect(runner._failed?).to be true
|
44
54
|
end
|
55
|
+
|
45
56
|
it 'makes block safe from UnauthorizedError' do
|
46
|
-
result =
|
57
|
+
result = runner._rescue_connection_failures do
|
47
58
|
raise Percy::Client::UnauthorizedError.new(401, 'GET', '', '')
|
48
59
|
end
|
49
|
-
|
50
|
-
expect(
|
60
|
+
|
61
|
+
expect(result).to be_nil
|
62
|
+
expect(runner._failed?).to be true
|
51
63
|
end
|
64
|
+
|
52
65
|
it 'makes block safe from TimeoutError' do
|
53
|
-
result =
|
54
|
-
|
55
|
-
|
56
|
-
expect(
|
57
|
-
expect(cli.send(:failed?)).to eq(true)
|
66
|
+
result = runner._rescue_connection_failures { raise Percy::Client::TimeoutError }
|
67
|
+
|
68
|
+
expect(result).to be_nil
|
69
|
+
expect(runner._failed?).to be true
|
58
70
|
end
|
71
|
+
|
59
72
|
it 'requires a block' do
|
60
|
-
expect {
|
73
|
+
expect { runner._rescue_connection_failures }.to raise_error(ArgumentError)
|
61
74
|
end
|
62
75
|
end
|
63
|
-
|
76
|
+
|
77
|
+
describe '#_find_root_paths' do
|
64
78
|
it 'returns only the HTML files in the directory' do
|
65
|
-
paths =
|
79
|
+
paths = runner._find_root_paths root_dir
|
80
|
+
|
66
81
|
expect(paths).to match_array(
|
67
82
|
[
|
68
83
|
File.join(root_dir, 'index.html'),
|
@@ -76,9 +91,11 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
76
91
|
)
|
77
92
|
end
|
78
93
|
end
|
79
|
-
|
94
|
+
|
95
|
+
describe '#_find_resource_paths' do
|
80
96
|
it 'returns only the related static files in the directory' do
|
81
|
-
paths =
|
97
|
+
paths = runner._find_resource_paths root_dir
|
98
|
+
|
82
99
|
expect(paths).to match_array(
|
83
100
|
[
|
84
101
|
File.join(root_dir, 'css/base.css'),
|
@@ -95,11 +112,12 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
95
112
|
)
|
96
113
|
end
|
97
114
|
end
|
98
|
-
|
115
|
+
|
116
|
+
describe '#_list_resources' do
|
99
117
|
it 'returns resource objects' do
|
100
118
|
paths = [File.join(root_dir, 'css/base.css')]
|
101
119
|
options = {baseurl: '/', strip_prefix: root_dir}
|
102
|
-
resources =
|
120
|
+
resources = runner._list_resources paths, options
|
103
121
|
|
104
122
|
expect(resources.length).to eq(1)
|
105
123
|
expect(resources.first.sha).to eq(Digest::SHA256.hexdigest(File.read(paths.first)))
|
@@ -107,18 +125,20 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
107
125
|
expect(resources.first.content).to be_nil
|
108
126
|
expect(resources.first.path).to eq(paths.first)
|
109
127
|
end
|
128
|
+
|
110
129
|
it 'correctly strips the prefix from resource_url' do
|
111
130
|
paths = [File.join(root_dir, 'index.html')]
|
112
131
|
options = {baseurl: '/', strip_prefix: root_dir_relative, is_root: true}
|
113
|
-
resources =
|
132
|
+
resources = runner._list_resources paths, options
|
114
133
|
|
115
134
|
expect(resources.length).to eq(1)
|
116
135
|
expect(resources.first.resource_url).to eq('/index.html')
|
117
136
|
end
|
137
|
+
|
118
138
|
it 'returns resource objects with is_root set if given' do
|
119
139
|
paths = [File.join(root_dir, 'index.html')]
|
120
140
|
options = {baseurl: '/', strip_prefix: root_dir, is_root: true}
|
121
|
-
resources =
|
141
|
+
resources = runner._list_resources paths, options
|
122
142
|
|
123
143
|
expect(resources.length).to eq(1)
|
124
144
|
expect(resources.first.resource_url).to eq('/index.html')
|
@@ -127,10 +147,11 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
127
147
|
expect(resources.first.content).to be_nil
|
128
148
|
expect(resources.first.path).to eq(paths.first)
|
129
149
|
end
|
150
|
+
|
130
151
|
it 'encodes the resource_url' do
|
131
152
|
paths = [File.join(root_dir, 'css/test with spaces.css')]
|
132
153
|
options = {baseurl: '/', strip_prefix: root_dir}
|
133
|
-
resources =
|
154
|
+
resources = runner._list_resources paths, options
|
134
155
|
|
135
156
|
expect(resources.length).to eq(1)
|
136
157
|
expect(resources.first.resource_url).to eq('/css/test%20with%20spaces.css')
|
@@ -139,10 +160,11 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
139
160
|
expect(resources.first.content).to be_nil
|
140
161
|
expect(resources.first.path).to eq(paths.first)
|
141
162
|
end
|
163
|
+
|
142
164
|
it 'prepends the baseurl if given' do
|
143
165
|
paths = [File.join(root_dir, 'index.html')]
|
144
166
|
options = {strip_prefix: root_dir, is_root: true, baseurl: '/test baseurl/'}
|
145
|
-
resources =
|
167
|
+
resources = runner._list_resources paths, options
|
146
168
|
|
147
169
|
expect(resources.length).to eq(1)
|
148
170
|
expect(resources.first.resource_url).to eq('/test%20baseurl/index.html')
|
@@ -152,6 +174,7 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
152
174
|
expect(resources.first.path).to eq(paths.first)
|
153
175
|
end
|
154
176
|
end
|
177
|
+
|
155
178
|
describe '#upload_snapshot' do
|
156
179
|
xit 'uploads the given resources to the build' do
|
157
180
|
# TODO(fotinakis): tests for this.
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<!DOCTYPE html><html>Hello World!</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.9
|
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-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -124,24 +124,23 @@ files:
|
|
124
124
|
- Gemfile
|
125
125
|
- LICENSE
|
126
126
|
- README.md
|
127
|
+
- RELEASING.md
|
127
128
|
- Rakefile
|
128
129
|
- bin/percy
|
129
130
|
- lib/percy/cli.rb
|
130
|
-
- lib/percy/cli/
|
131
|
+
- lib/percy/cli/snapshot_runner.rb
|
131
132
|
- lib/percy/cli/version.rb
|
132
133
|
- percy-cli.gemspec
|
133
|
-
- spec/percy/cli/
|
134
|
+
- spec/percy/cli/snapshot_runner_spec.rb
|
134
135
|
- spec/percy/cli/testdata/css/base.css
|
135
136
|
- spec/percy/cli/testdata/css/test with spaces.css
|
136
137
|
- spec/percy/cli/testdata/css/unrelated-no-extension
|
137
138
|
- spec/percy/cli/testdata/images/jellybeans-symlink.png
|
138
139
|
- spec/percy/cli/testdata/images/jellybeans.png
|
139
140
|
- spec/percy/cli/testdata/images/large-file-skipped.png
|
140
|
-
- spec/percy/cli/testdata/images_symlink
|
141
141
|
- spec/percy/cli/testdata/index.html
|
142
142
|
- spec/percy/cli/testdata/subdir/test.html
|
143
143
|
- spec/percy/cli/testdata/subdir/test_symlink.html
|
144
|
-
- spec/percy/cli/testdata/subdir_symlink
|
145
144
|
- spec/spec_helper.rb
|
146
145
|
homepage: ''
|
147
146
|
licenses:
|
@@ -163,21 +162,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
162
|
version: '0'
|
164
163
|
requirements: []
|
165
164
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.4.5.2
|
167
166
|
signing_key:
|
168
167
|
specification_version: 4
|
169
168
|
summary: Percy command-line interface
|
170
169
|
test_files:
|
171
|
-
- spec/percy/cli/
|
170
|
+
- spec/percy/cli/snapshot_runner_spec.rb
|
172
171
|
- spec/percy/cli/testdata/css/base.css
|
173
172
|
- spec/percy/cli/testdata/css/test with spaces.css
|
174
173
|
- spec/percy/cli/testdata/css/unrelated-no-extension
|
175
174
|
- spec/percy/cli/testdata/images/jellybeans-symlink.png
|
176
175
|
- spec/percy/cli/testdata/images/jellybeans.png
|
177
176
|
- spec/percy/cli/testdata/images/large-file-skipped.png
|
178
|
-
- spec/percy/cli/testdata/images_symlink
|
179
177
|
- spec/percy/cli/testdata/index.html
|
180
178
|
- spec/percy/cli/testdata/subdir/test.html
|
181
179
|
- spec/percy/cli/testdata/subdir/test_symlink.html
|
182
|
-
- spec/percy/cli/testdata/subdir_symlink
|
183
180
|
- spec/spec_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
spec/percy/cli/testdata/images/jellybeans.png
|
@@ -1 +0,0 @@
|
|
1
|
-
spec/percy/cli/testdata/images/
|
@@ -1 +0,0 @@
|
|
1
|
-
spec/percy/cli/testdata/subdir/test.html
|
@@ -1 +0,0 @@
|
|
1
|
-
spec/percy/cli/testdata/subdir
|