prawn-svg 0.34.2 → 0.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +19 -0
  3. data/.github/workflows/test.yml +14 -27
  4. data/.gitignore +0 -1
  5. data/.rubocop.yml +86 -0
  6. data/.rubocop_todo.yml +51 -0
  7. data/Gemfile +4 -3
  8. data/Gemfile.lock +81 -0
  9. data/README.md +1 -1
  10. data/Rakefile +1 -1
  11. data/lib/prawn/svg/attributes/clip_path.rb +3 -3
  12. data/lib/prawn/svg/attributes/opacity.rb +3 -3
  13. data/lib/prawn/svg/attributes/stroke.rb +9 -9
  14. data/lib/prawn/svg/attributes/transform.rb +2 -2
  15. data/lib/prawn/svg/attributes.rb +1 -1
  16. data/lib/prawn/svg/calculators/arc_to_bezier_curve.rb +17 -15
  17. data/lib/prawn/svg/calculators/aspect_ratio.rb +16 -14
  18. data/lib/prawn/svg/calculators/document_sizing.rb +9 -10
  19. data/lib/prawn/svg/calculators/pixels.rb +8 -5
  20. data/lib/prawn/svg/color.rb +209 -212
  21. data/lib/prawn/svg/css/font_family_parser.rb +2 -2
  22. data/lib/prawn/svg/css/selector_parser.rb +39 -35
  23. data/lib/prawn/svg/css/stylesheets.rb +24 -24
  24. data/lib/prawn/svg/css/values_parser.rb +68 -0
  25. data/lib/prawn/svg/document.rb +6 -5
  26. data/lib/prawn/svg/elements/base.rb +29 -34
  27. data/lib/prawn/svg/elements/circle.rb +4 -4
  28. data/lib/prawn/svg/elements/clip_path.rb +0 -1
  29. data/lib/prawn/svg/elements/depth_first_base.rb +6 -6
  30. data/lib/prawn/svg/elements/ellipse.rb +3 -4
  31. data/lib/prawn/svg/elements/gradient.rb +49 -51
  32. data/lib/prawn/svg/elements/image.rb +5 -5
  33. data/lib/prawn/svg/elements/marker.rb +5 -5
  34. data/lib/prawn/svg/elements/path.rb +46 -47
  35. data/lib/prawn/svg/elements/polygon.rb +1 -1
  36. data/lib/prawn/svg/elements/polyline.rb +2 -2
  37. data/lib/prawn/svg/elements/rect.rb +3 -3
  38. data/lib/prawn/svg/elements/text.rb +1 -1
  39. data/lib/prawn/svg/elements/text_component.rb +22 -22
  40. data/lib/prawn/svg/elements/use.rb +3 -7
  41. data/lib/prawn/svg/elements/viewport.rb +1 -3
  42. data/lib/prawn/svg/elements.rb +30 -29
  43. data/lib/prawn/svg/extension.rb +2 -1
  44. data/lib/prawn/svg/font.rb +7 -7
  45. data/lib/prawn/svg/font_registry.rb +13 -13
  46. data/lib/prawn/svg/gradients.rb +3 -2
  47. data/lib/prawn/svg/interface.rb +4 -3
  48. data/lib/prawn/svg/loaders/data.rb +2 -2
  49. data/lib/prawn/svg/loaders/file.rb +12 -14
  50. data/lib/prawn/svg/loaders/web.rb +4 -8
  51. data/lib/prawn/svg/pathable.rb +41 -37
  52. data/lib/prawn/svg/properties.rb +34 -33
  53. data/lib/prawn/svg/renderer.rb +7 -7
  54. data/lib/prawn/svg/state.rb +1 -1
  55. data/lib/prawn/svg/transform_parser.rb +5 -5
  56. data/lib/prawn/svg/ttf.rb +21 -17
  57. data/lib/prawn/svg/url_loader.rb +1 -1
  58. data/lib/prawn/svg/version.rb +1 -1
  59. data/lib/prawn-svg.rb +1 -0
  60. data/prawn-svg.gemspec +4 -6
  61. data/spec/integration_spec.rb +77 -70
  62. data/spec/prawn/svg/attributes/opacity_spec.rb +11 -15
  63. data/spec/prawn/svg/attributes/transform_spec.rb +6 -6
  64. data/spec/prawn/svg/calculators/aspect_ratio_spec.rb +50 -50
  65. data/spec/prawn/svg/calculators/document_sizing_spec.rb +35 -35
  66. data/spec/prawn/svg/calculators/pixels_spec.rb +31 -30
  67. data/spec/prawn/svg/color_spec.rb +31 -31
  68. data/spec/prawn/svg/css/font_family_parser_spec.rb +12 -12
  69. data/spec/prawn/svg/css/selector_parser_spec.rb +21 -21
  70. data/spec/prawn/svg/css/stylesheets_spec.rb +51 -45
  71. data/spec/prawn/svg/css/values_parser_spec.rb +16 -0
  72. data/spec/prawn/svg/document_spec.rb +15 -14
  73. data/spec/prawn/svg/elements/base_spec.rb +39 -34
  74. data/spec/prawn/svg/elements/gradient_spec.rb +39 -39
  75. data/spec/prawn/svg/elements/line_spec.rb +22 -22
  76. data/spec/prawn/svg/elements/marker_spec.rb +36 -40
  77. data/spec/prawn/svg/elements/path_spec.rb +134 -110
  78. data/spec/prawn/svg/elements/polygon_spec.rb +18 -18
  79. data/spec/prawn/svg/elements/polyline_spec.rb +16 -16
  80. data/spec/prawn/svg/elements/text_spec.rb +149 -127
  81. data/spec/prawn/svg/font_registry_spec.rb +34 -34
  82. data/spec/prawn/svg/font_spec.rb +4 -4
  83. data/spec/prawn/svg/interface_spec.rb +47 -39
  84. data/spec/prawn/svg/loaders/data_spec.rb +21 -21
  85. data/spec/prawn/svg/loaders/file_spec.rb +43 -40
  86. data/spec/prawn/svg/loaders/web_spec.rb +15 -15
  87. data/spec/prawn/svg/pathable_spec.rb +21 -21
  88. data/spec/prawn/svg/properties_spec.rb +51 -51
  89. data/spec/prawn/svg/transform_parser_spec.rb +12 -12
  90. data/spec/prawn/svg/ttf_spec.rb +5 -5
  91. data/spec/prawn/svg/url_loader_spec.rb +25 -23
  92. data/spec/spec_helper.rb +4 -4
  93. metadata +12 -143
@@ -3,27 +3,27 @@ require 'spec_helper'
3
3
  RSpec.describe Prawn::SVG::Properties do
4
4
  subject { Prawn::SVG::Properties.new }
5
5
 
6
- describe "#load_default_stylesheet" do
7
- it "loads in the defaults and returns self" do
6
+ describe '#load_default_stylesheet' do
7
+ it 'loads in the defaults and returns self' do
8
8
  expect(subject.load_default_stylesheet).to eq subject
9
9
  expect(subject.font_family).to eq 'sans-serif'
10
10
  end
11
11
  end
12
12
 
13
- describe "#set" do
14
- it "sets a property" do
13
+ describe '#set' do
14
+ it 'sets a property' do
15
15
  result = subject.set('color', 'red')
16
16
  expect(result).to be
17
17
  expect(subject.color).to eq 'red'
18
18
  end
19
19
 
20
- it "handles property names that are not lower case" do
20
+ it 'handles property names that are not lower case' do
21
21
  result = subject.set('COLor', 'red')
22
22
  expect(result).to be
23
23
  expect(subject.color).to eq 'red'
24
24
  end
25
25
 
26
- it "right-cases and strips keywords" do
26
+ it 'right-cases and strips keywords' do
27
27
  subject.set('stroke-linecap', ' Round ')
28
28
  expect(subject.stroke_linecap).to eq 'round'
29
29
  end
@@ -39,19 +39,19 @@ RSpec.describe Prawn::SVG::Properties do
39
39
  end
40
40
  end
41
41
 
42
- describe "#load_hash" do
43
- it "uses #set to load in a hash of properties" do
44
- subject.load_hash("stroke" => "blue", "fill" => "green", 'stroke-linecap' => "Round")
42
+ describe '#load_hash' do
43
+ it 'uses #set to load in a hash of properties' do
44
+ subject.load_hash('stroke' => 'blue', 'fill' => 'green', 'stroke-linecap' => 'Round')
45
45
  expect(subject.stroke).to eq 'blue'
46
46
  expect(subject.fill).to eq 'green'
47
47
  expect(subject.stroke_linecap).to eq 'round'
48
48
  end
49
49
  end
50
50
 
51
- describe "#compute_properties" do
51
+ describe '#compute_properties' do
52
52
  let(:other) { Prawn::SVG::Properties.new }
53
53
 
54
- it "auto-inherits inheritable properties when the property is not supplied" do
54
+ it 'auto-inherits inheritable properties when the property is not supplied' do
55
55
  subject.set('color', 'green')
56
56
  subject.compute_properties(other)
57
57
  expect(subject.color).to eq 'green'
@@ -63,122 +63,122 @@ RSpec.describe Prawn::SVG::Properties do
63
63
  expect(subject.display).to eq 'inline'
64
64
  end
65
65
 
66
- it "inherits non-inheritable properties when specifically asked to" do
66
+ it 'inherits non-inheritable properties when specifically asked to' do
67
67
  subject.set('display', 'none')
68
68
  other.set('display', 'inherit')
69
69
  subject.compute_properties(other)
70
70
  expect(subject.display).to eq 'none'
71
71
  end
72
72
 
73
- it "uses the new property value" do
73
+ it 'uses the new property value' do
74
74
  subject.set('color', 'green')
75
75
  other.set('color', 'red')
76
76
  subject.compute_properties(other)
77
77
  expect(subject.color).to eq 'red'
78
78
  end
79
79
 
80
- describe "font size" do
80
+ describe 'font size' do
81
81
  before do
82
- subject.font_size = "15"
82
+ subject.font_size = '15'
83
83
  other.font_size = font_size
84
84
  end
85
85
 
86
- context "when given a % as a font-size" do
87
- let(:font_size) { "120%" }
86
+ context 'when given a % as a font-size' do
87
+ let(:font_size) { '120%' }
88
88
 
89
- it "calculates the new font size" do
89
+ it 'calculates the new font size' do
90
90
  subject.compute_properties(other)
91
- expect(subject.font_size).to eq "18.0"
91
+ expect(subject.font_size).to eq '18.0'
92
92
  end
93
93
  end
94
94
 
95
95
  context "when given 'larger' as a font-size" do
96
- let(:font_size) { "larger" }
96
+ let(:font_size) { 'larger' }
97
97
 
98
- it "calculates the new font size" do
98
+ it 'calculates the new font size' do
99
99
  subject.compute_properties(other)
100
- expect(subject.font_size).to eq "19.0"
100
+ expect(subject.font_size).to eq '19.0'
101
101
  end
102
102
  end
103
103
 
104
104
  context "when given 'smaller' as a font-size" do
105
- let(:font_size) { "smaller" }
105
+ let(:font_size) { 'smaller' }
106
106
 
107
- it "calculates the new font size" do
107
+ it 'calculates the new font size' do
108
108
  subject.compute_properties(other)
109
- expect(subject.font_size).to eq "11.0"
109
+ expect(subject.font_size).to eq '11.0'
110
110
  end
111
111
  end
112
112
 
113
113
  context "when given a value in 'em' as a font-size" do
114
- let(:font_size) { "2.5em" }
114
+ let(:font_size) { '2.5em' }
115
115
 
116
- it "calculates the new font size" do
116
+ it 'calculates the new font size' do
117
117
  subject.compute_properties(other)
118
- expect(subject.font_size).to eq "37.5"
118
+ expect(subject.font_size).to eq '37.5'
119
119
  end
120
120
  end
121
121
 
122
122
  context "when given a value in 'rem' as a font-size" do
123
- let(:font_size) { "2.5rem" }
123
+ let(:font_size) { '2.5rem' }
124
124
 
125
- it "calculates the new font size" do
125
+ it 'calculates the new font size' do
126
126
  subject.compute_properties(other)
127
- expect(subject.font_size).to eq "40.0"
127
+ expect(subject.font_size).to eq '40.0'
128
128
  end
129
129
  end
130
130
 
131
131
  context "when given a value in 'px' as a font-size" do
132
- let(:font_size) { "19.5px" }
132
+ let(:font_size) { '19.5px' }
133
133
 
134
- it "uses the font size specified" do
134
+ it 'uses the font size specified' do
135
135
  subject.compute_properties(other)
136
- expect(subject.font_size).to eq "19.5"
136
+ expect(subject.font_size).to eq '19.5'
137
137
  end
138
138
  end
139
139
 
140
140
  context "when given a value in 'pt' as a font-size" do
141
- let(:font_size) { "19.5pt" }
141
+ let(:font_size) { '19.5pt' }
142
142
 
143
- it "uses the font size specified" do
143
+ it 'uses the font size specified' do
144
144
  subject.compute_properties(other)
145
- expect(subject.font_size).to eq "19.5"
145
+ expect(subject.font_size).to eq '19.5'
146
146
  end
147
147
  end
148
148
 
149
- context "when given a value without units as a font-size" do
150
- let(:font_size) { "19.5" }
149
+ context 'when given a value without units as a font-size' do
150
+ let(:font_size) { '19.5' }
151
151
 
152
- it "uses the font size specified" do
152
+ it 'uses the font size specified' do
153
153
  subject.compute_properties(other)
154
- expect(subject.font_size).to eq "19.5"
154
+ expect(subject.font_size).to eq '19.5'
155
155
  end
156
156
  end
157
157
 
158
158
  context "when given the keyword 'inherit' as a font-size" do
159
- let(:font_size) { "inherit" }
159
+ let(:font_size) { 'inherit' }
160
160
 
161
- it "uses the font size specified by the parent" do
161
+ it 'uses the font size specified by the parent' do
162
162
  subject.compute_properties(other)
163
- expect(subject.font_size).to eq "15"
163
+ expect(subject.font_size).to eq '15'
164
164
  end
165
165
  end
166
166
  end
167
167
  end
168
168
 
169
- describe "#numerical_font_size" do
170
- context "when the font size is a number" do
171
- before { subject.font_size = "16.5" }
169
+ describe '#numerical_font_size' do
170
+ context 'when the font size is a number' do
171
+ before { subject.font_size = '16.5' }
172
172
 
173
- it "returns the number as a float" do
173
+ it 'returns the number as a float' do
174
174
  expect(subject.numerical_font_size).to eq 16.5
175
175
  end
176
176
  end
177
177
 
178
- context "when the font size is one of the keyword size specifiers" do
179
- before { subject.font_size = "x-large" }
178
+ context 'when the font size is one of the keyword size specifiers' do
179
+ before { subject.font_size = 'x-large' }
180
180
 
181
- it "returns the font size number corresponding with the keyword" do
181
+ it 'returns the font size number corresponding with the keyword' do
182
182
  expect(subject.numerical_font_size).to eq 24
183
183
  end
184
184
  end
@@ -28,27 +28,27 @@ RSpec.describe Prawn::SVG::TransformParser do
28
28
 
29
29
  subject { Test.new.parse_transform_attribute(transform) }
30
30
 
31
- context "with no transform" do
31
+ context 'with no transform' do
32
32
  let(:transform) { '' }
33
33
  it { is_expected.to eq [1, 0, 0, 1, 0, 0] }
34
34
  end
35
35
 
36
- context "with translate" do
36
+ context 'with translate' do
37
37
  let(:transform) { 'translate(10 20)' }
38
38
  it { is_expected.to eq [1, 0, 0, 1, 10, -20] }
39
39
  end
40
40
 
41
- context "with single argument translate" do
41
+ context 'with single argument translate' do
42
42
  let(:transform) { 'translate(10)' }
43
43
  it { is_expected.to eq [1, 0, 0, 1, 10, 0] }
44
44
  end
45
45
 
46
- context "with translateX" do
46
+ context 'with translateX' do
47
47
  let(:transform) { 'translateX(10)' }
48
48
  it { is_expected.to eq [1, 0, 0, 1, 10, 0] }
49
49
  end
50
50
 
51
- context "with translateY" do
51
+ context 'with translateY' do
52
52
  let(:transform) { 'translateY(10)' }
53
53
  it { is_expected.to eq [1, 0, 0, 1, 0, -10] }
54
54
  end
@@ -57,37 +57,37 @@ RSpec.describe Prawn::SVG::TransformParser do
57
57
  let(:cos30) { Math.cos(30 * Math::PI / 180.0) }
58
58
  let(:tan30) { Math.tan(30 * Math::PI / 180.0) }
59
59
 
60
- context "with single argument rotate" do
60
+ context 'with single argument rotate' do
61
61
  let(:transform) { 'rotate(30)' }
62
62
  it { is_expected.to eq [cos30, -sin30, sin30, cos30, 0, 0] }
63
63
  end
64
64
 
65
- context "with triple argument rotate" do
65
+ context 'with triple argument rotate' do
66
66
  let(:transform) { 'rotate(30 100 200)' }
67
67
  it { is_expected.to eq [cos30, -sin30, sin30, cos30, 113.39745962155611, 23.205080756887753] }
68
68
  end
69
69
 
70
- context "with scale" do
70
+ context 'with scale' do
71
71
  let(:transform) { 'scale(1.5)' }
72
72
  it { is_expected.to eq [1.5, 0, 0, 1.5, 0, 0] }
73
73
  end
74
74
 
75
- context "with skewX" do
75
+ context 'with skewX' do
76
76
  let(:transform) { 'skewX(30)' }
77
77
  it { is_expected.to eq [1, 0, -tan30, 1, 0, 0] }
78
78
  end
79
79
 
80
- context "with skewY" do
80
+ context 'with skewY' do
81
81
  let(:transform) { 'skewY(30)' }
82
82
  it { is_expected.to eq [1, -tan30, 0, 1, 0, 0] }
83
83
  end
84
84
 
85
- context "with matrix" do
85
+ context 'with matrix' do
86
86
  let(:transform) { 'matrix(1 2 3 4 5 6)' }
87
87
  it { is_expected.to eq [1, -2, -3, 4, 5, -6] }
88
88
  end
89
89
 
90
- context "with multiple" do
90
+ context 'with multiple' do
91
91
  let(:transform) { 'scale(2) translate(7) scale(3)' }
92
92
  it { is_expected.to eq [6, 0, 0, 6, 14, 0] }
93
93
  end
@@ -3,10 +3,10 @@ require 'spec_helper'
3
3
  RSpec.describe Prawn::SVG::TTF do
4
4
  subject { Prawn::SVG::TTF.new(filename) }
5
5
 
6
- context "with a truetype font" do
6
+ context 'with a truetype font' do
7
7
  let(:filename) { "#{File.dirname(__FILE__)}/../../sample_ttf/OpenSans-SemiboldItalic.ttf" }
8
8
 
9
- it "gets the English family and subfamily from the font file" do
9
+ it 'gets the English family and subfamily from the font file' do
10
10
  expect(subject.family).to eq 'Open Sans'
11
11
  expect(subject.subfamily).to eq 'Semibold Italic'
12
12
  end
@@ -15,16 +15,16 @@ RSpec.describe Prawn::SVG::TTF do
15
15
  context "with a file that isn't a TTF" do
16
16
  let(:filename) { __FILE__ }
17
17
 
18
- it "has a nil family and subfamily" do
18
+ it 'has a nil family and subfamily' do
19
19
  expect(subject.family).to be nil
20
20
  expect(subject.subfamily).to be nil
21
21
  end
22
22
  end
23
23
 
24
24
  context "with a file that doesn't exist" do
25
- let(:filename) { "does_not_exist" }
25
+ let(:filename) { 'does_not_exist' }
26
26
 
27
- it "has a nil family and subfamily" do
27
+ it 'has a nil family and subfamily' do
28
28
  expect(subject.family).to be nil
29
29
  expect(subject.subfamily).to be nil
30
30
  end
@@ -3,17 +3,19 @@ require 'spec_helper'
3
3
  describe Prawn::SVG::UrlLoader do
4
4
  let(:enable_cache) { true }
5
5
  let(:enable_web) { true }
6
- let(:enable_file) { "." }
7
- let(:loader) { Prawn::SVG::UrlLoader.new(enable_cache: enable_cache, enable_web: enable_web, enable_file_with_root: enable_file) }
6
+ let(:enable_file) { '.' }
7
+ let(:loader) do
8
+ Prawn::SVG::UrlLoader.new(enable_cache: enable_cache, enable_web: enable_web, enable_file_with_root: enable_file)
9
+ end
8
10
 
9
- describe "#initialize" do
10
- it "sets options" do
11
+ describe '#initialize' do
12
+ it 'sets options' do
11
13
  expect(loader.enable_cache).to be true
12
14
  end
13
15
  end
14
16
 
15
- describe "#load" do
16
- let(:url) { "http://hello/there" }
17
+ describe '#load' do
18
+ let(:url) { 'http://hello/there' }
17
19
  let(:data_loader) { instance_double(Prawn::SVG::Loaders::Data) }
18
20
  let(:web_loader) { instance_double(Prawn::SVG::Loaders::Web) }
19
21
  let(:file_loader) { instance_double(Prawn::SVG::Loaders::File) }
@@ -26,29 +28,29 @@ describe Prawn::SVG::UrlLoader do
26
28
 
27
29
  subject { loader.load(url) }
28
30
 
29
- it "calls the Data loader and returns its output if successful" do
30
- expect(data_loader).to receive(:from_url).with(url).and_return("data")
31
+ it 'calls the Data loader and returns its output if successful' do
32
+ expect(data_loader).to receive(:from_url).with(url).and_return('data')
31
33
  expect(web_loader).not_to receive(:from_url)
32
34
 
33
35
  expect(subject).to eq 'data'
34
36
  end
35
37
 
36
- it "calls the Web loader if the Data loader returns nothing, and returns its output if successful" do
38
+ it 'calls the Web loader if the Data loader returns nothing, and returns its output if successful' do
37
39
  expect(data_loader).to receive(:from_url).with(url)
38
- expect(web_loader).to receive(:from_url).with(url).and_return("data")
40
+ expect(web_loader).to receive(:from_url).with(url).and_return('data')
39
41
 
40
42
  expect(subject).to eq 'data'
41
43
  end
42
44
 
43
- it "calls the File loader if the Data and Web loaders return nothing, and returns its output if successful" do
45
+ it 'calls the File loader if the Data and Web loaders return nothing, and returns its output if successful' do
44
46
  expect(data_loader).to receive(:from_url).with(url)
45
47
  expect(web_loader).to receive(:from_url).with(url)
46
- expect(file_loader).to receive(:from_url).with(url).and_return("data")
48
+ expect(file_loader).to receive(:from_url).with(url).and_return('data')
47
49
 
48
50
  expect(subject).to eq 'data'
49
51
  end
50
52
 
51
- it "raises if none of the loaders return any data" do
53
+ it 'raises if none of the loaders return any data' do
52
54
  expect(data_loader).to receive(:from_url).with(url)
53
55
  expect(web_loader).to receive(:from_url).with(url)
54
56
  expect(file_loader).to receive(:from_url).with(url)
@@ -56,28 +58,28 @@ describe Prawn::SVG::UrlLoader do
56
58
  expect { subject }.to raise_error(Prawn::SVG::UrlLoader::Error, /No handler available/)
57
59
  end
58
60
 
59
- context "when caching is enabled" do
60
- it "caches the result" do
61
- expect(data_loader).to receive(:from_url).with(url).and_return("data")
61
+ context 'when caching is enabled' do
62
+ it 'caches the result' do
63
+ expect(data_loader).to receive(:from_url).with(url).and_return('data')
62
64
  expect(subject).to eq 'data'
63
65
  expect(loader.retrieve_from_cache(url)).to eq 'data'
64
66
  end
65
67
  end
66
68
 
67
- context "when caching is disabled" do
69
+ context 'when caching is disabled' do
68
70
  let(:enable_cache) { false }
69
71
 
70
- it "does not cache the result" do
71
- expect(data_loader).to receive(:from_url).with(url).and_return("data")
72
+ it 'does not cache the result' do
73
+ expect(data_loader).to receive(:from_url).with(url).and_return('data')
72
74
  expect(subject).to eq 'data'
73
75
  expect(loader.retrieve_from_cache(url)).to be nil
74
76
  end
75
77
  end
76
78
 
77
- context "when the cache is populated" do
79
+ context 'when the cache is populated' do
78
80
  before { loader.add_to_cache(url, 'data') }
79
81
 
80
- it "returns the cached value without calling a loader" do
82
+ it 'returns the cached value without calling a loader' do
81
83
  expect(data_loader).not_to receive(:from_url)
82
84
  expect(web_loader).not_to receive(:from_url)
83
85
 
@@ -85,7 +87,7 @@ describe Prawn::SVG::UrlLoader do
85
87
  end
86
88
  end
87
89
 
88
- context "when web requests are disabled" do
90
+ context 'when web requests are disabled' do
89
91
  let(:enable_web) { false }
90
92
 
91
93
  it "doesn't use the web loader" do
@@ -97,7 +99,7 @@ describe Prawn::SVG::UrlLoader do
97
99
  end
98
100
  end
99
101
 
100
- context "when file requests are disabled" do
102
+ context 'when file requests are disabled' do
101
103
  let(:enable_file) { nil }
102
104
 
103
105
  it "doesn't use the file loader" do
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,7 @@ Bundler.require(:default, :development)
3
3
 
4
4
  # Requires supporting files with custom matchers and macros, etc,
5
5
  # in ./support/ and its subdirectories.
6
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
7
7
 
8
8
  module Support
9
9
  def flatten_calls(_calls)
@@ -49,15 +49,15 @@ RSpec.configure do |config|
49
49
 
50
50
  config.after(:suite) do
51
51
  # print out the PDFs that have changed
52
- changed = $hashes.select do |file, hash|
52
+ changed = $hashes.reject do |file, hash|
53
53
  new_hash = Digest::MD5.file(file).hexdigest
54
- new_hash != hash
54
+ new_hash == hash
55
55
  end
56
56
 
57
57
  if changed.any?
58
58
  puts "\nThese PDFs have changed since the last test run:"
59
59
  cwd = "#{Dir.pwd}/"
60
- changed.each { |file, _| puts " #{file.sub(cwd, '')}" }
60
+ changed.each_key { |file| puts " #{file.sub(cwd, '')}" }
61
61
  end
62
62
  end
63
63
  end