svgo_wrapper 0.0.3 → 0.0.4

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: 76a70d96f217e4b058f67f606d9ba17ddef9f777
4
- data.tar.gz: fe0c8f2ed99d09b63a53e445a9db99c373e19bf2
3
+ metadata.gz: 3a40cd66303349f126ac7403993e9e49c4d70c03
4
+ data.tar.gz: c7fd377d1a46ec6441dff7866efa36bb8c81d8eb
5
5
  SHA512:
6
- metadata.gz: c5c86c5f59bd2e820d14a15e7bc4f2571ab604d6f2e987e070582dc8c1785b59854cd9f9d91c7589db44fea8b47ef23b6b5d8dd25aaf7406416d05f3d908c841
7
- data.tar.gz: 4c8c053e552c484cb2d23c162288515c55f9ca1012ed0c5f39b4d1787f3761c29596eb77d3fcd0372ac2998c1d98517cec8e9c4678188be64ae13ccd20b52bb6
6
+ metadata.gz: 1e6a39d65c1646e5164aa09d54854a23e8173a60219030f145102aca2d4bc44b0d6aa9cda03f39edbbb553ecbe833753753899ea4eef5c8699434a8968512ca3
7
+ data.tar.gz: f43d1cfafc2ef8ed34f8002b81262ea27dd36011f1403e513c0e5bffe598af38e59580157bad744f1036efba44c2c570b7e6282369e90563c924dd56e3ebd4ef
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.0
@@ -28,7 +28,7 @@ class SvgoWrapper
28
28
  raise Error, "Unexpected error (#{e.exitstatus})\n"
29
29
  end
30
30
 
31
- raise ParserError, output unless output =~ /<svg/
31
+ verify_output(output)
32
32
  output
33
33
  end
34
34
 
@@ -60,4 +60,11 @@ class SvgoWrapper
60
60
  (disabled.map {|v| "--disable=#{v}".freeze } +
61
61
  enabled.map {|v| "--enable=#{v}".freeze }).freeze
62
62
  end
63
+
64
+ def verify_output(output)
65
+ return if output =~ /<svg/
66
+
67
+ output = "There was a problem optimizing the SVG image with the selected plugins\n" if output.strip.empty?
68
+ raise ParserError, output
69
+ end
63
70
  end
@@ -1,3 +1,3 @@
1
1
  class SvgoWrapper
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
@@ -152,25 +152,38 @@ describe SvgoWrapper do
152
152
  end
153
153
  end
154
154
 
155
- context "`svgo` tool unexpectedly fails" do
156
- let(:mocked_status) do
157
- # A mock of Process::Status
158
- Object.new.tap do |o|
159
- o.instance_eval do
160
- define_singleton_method :signaled?, proc { false }
161
- define_singleton_method :exitstatus, proc { 123 }
162
- end
155
+ describe "`svgo` tool" do
156
+ context "returns an empty string" do
157
+ let(:svg_image) { " <svg/>" }
158
+
159
+ subject { described_class.new(enable: :transformsWithOnePath).optimize_images_data svg_image }
160
+
161
+ it "raises a descriptive exception" do
162
+ expect { subject }.to raise_error(described_class::ParserError, "There was a problem optimizing the SVG " \
163
+ "image with the selected plugins\n")
163
164
  end
164
165
  end
165
166
 
166
- subject { described_class.new.optimize_images_data svg_image }
167
+ context "unexpectedly fails" do
168
+ let(:mocked_status) do
169
+ # A mock of Process::Status
170
+ Object.new.tap do |o|
171
+ o.instance_eval do
172
+ define_singleton_method :signaled?, proc { false }
173
+ define_singleton_method :exitstatus, proc { 123 }
174
+ end
175
+ end
176
+ end
167
177
 
168
- before(:each) do
169
- allow(Open4).to receive(:spawn).and_raise(Open4::SpawnError.new("command example", mocked_status))
170
- end
178
+ subject { described_class.new.optimize_images_data svg_image }
171
179
 
172
- it "raises a general error" do
173
- expect { subject }.to raise_error(described_class::Error, "Unexpected error (123)\n")
180
+ before(:each) do
181
+ allow(Open4).to receive(:spawn).and_raise(Open4::SpawnError.new("command example", mocked_status))
182
+ end
183
+
184
+ it "raises a general error" do
185
+ expect { subject }.to raise_error(described_class::Error, "Unexpected error (123)\n")
186
+ end
174
187
  end
175
188
  end
176
189
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgo_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel de Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open4