fontcustom 1.2.0 → 1.3.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +35 -15
- data/TODO.md +20 -0
- data/lib/fontcustom.rb +11 -24
- data/lib/fontcustom/base.rb +56 -0
- data/lib/fontcustom/cli.rb +13 -12
- data/lib/fontcustom/generator/font.rb +63 -65
- data/lib/fontcustom/generator/template.rb +81 -52
- data/lib/fontcustom/manifest.rb +42 -0
- data/lib/fontcustom/options.rb +93 -80
- data/lib/fontcustom/scripts/generate.py +116 -127
- data/lib/fontcustom/templates/_fontcustom-rails.scss +13 -18
- data/lib/fontcustom/templates/_fontcustom.scss +10 -18
- data/lib/fontcustom/templates/fontcustom-preview.html +17 -24
- data/lib/fontcustom/templates/fontcustom.css +10 -18
- data/lib/fontcustom/templates/fontcustom.yml +3 -3
- data/lib/fontcustom/utility.rb +145 -0
- data/lib/fontcustom/version.rb +1 -1
- data/lib/fontcustom/watcher.rb +1 -1
- data/spec/fixtures/generators/.fontcustom-manifest-corrupted.json +12 -5
- data/spec/fixtures/generators/.fontcustom-manifest-empty.json +0 -0
- data/spec/fixtures/generators/.fontcustom-manifest.json +49 -14
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.eot +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.svg +56 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.ttf +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.woff +0 -0
- data/spec/fixtures/sandbox/.gitkeep +0 -0
- data/spec/fontcustom/base_spec.rb +58 -0
- data/spec/fontcustom/cli_spec.rb +15 -0
- data/spec/fontcustom/generator/font_spec.rb +50 -220
- data/spec/fontcustom/generator/template_spec.rb +30 -194
- data/spec/fontcustom/generator/template_spec.rb.off +215 -0
- data/spec/fontcustom/manifest_spec.rb +16 -0
- data/spec/fontcustom/options_spec.rb +206 -208
- data/spec/fontcustom/utility_spec.rb +163 -0
- data/spec/fontcustom/{watcher_spec.rb → watcher_spec.rb.off} +0 -0
- data/spec/spec_helper.rb +77 -19
- metadata +44 -54
- data/lib/fontcustom/templates/_fontcustom-bootstrap-ie7.scss +0 -22
- data/lib/fontcustom/templates/_fontcustom-bootstrap.scss +0 -63
- data/lib/fontcustom/templates/fontcustom-bootstrap-ie7.css +0 -22
- data/lib/fontcustom/templates/fontcustom-bootstrap.css +0 -63
- data/lib/fontcustom/util.rb +0 -62
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +0 -102
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
- data/spec/fontcustom/util_spec.rb +0 -82
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fontcustom::Manifest do
|
4
|
+
context "#initialize" do
|
5
|
+
it "should create a manifest file and set manifest[:options] (integration)", :integration => true do
|
6
|
+
live_test do |testdir|
|
7
|
+
capture(:stdout) do
|
8
|
+
options = Fontcustom::Options.new(:input => "vectors").options
|
9
|
+
Fontcustom::Manifest.new(options)
|
10
|
+
end
|
11
|
+
manifest = File.read File.join(testdir, ".fontcustom-manifest.json")
|
12
|
+
manifest.should match(/"options":.+sandbox\/test\/fontcustom/m)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Fontcustom::Options do
|
5
5
|
def options(args = {})
|
6
6
|
Fontcustom::Options.new(args)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
before(:each) do
|
10
10
|
Fontcustom::Options.any_instance.stub :say_message
|
11
|
+
Fontcustom::Options.any_instance.stub :parse_options
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
context "#initialize" do
|
14
|
+
context ".overwrite_examples" do
|
16
15
|
it "should overwite example defaults with real defaults" do
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
o = options(Fontcustom::EXAMPLE_OPTIONS.dup)
|
17
|
+
o.send :overwrite_examples
|
18
|
+
cli = o.instance_variable_get(:@cli_options)
|
20
19
|
Fontcustom::EXAMPLE_OPTIONS.keys.each do |key|
|
21
|
-
|
20
|
+
cli[key].should == Fontcustom::DEFAULT_OPTIONS[key] unless key == :project_root
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
@@ -26,339 +25,336 @@ describe Fontcustom::Options do
|
|
26
25
|
context ".set_config_path" do
|
27
26
|
context "when :config is set" do
|
28
27
|
it "should use options[:config] if it's a file" do
|
29
|
-
|
28
|
+
o = options(
|
30
29
|
:project_root => fixture,
|
31
30
|
:config => "options/any-file-name.yml"
|
32
|
-
|
33
|
-
o = options args
|
31
|
+
)
|
34
32
|
o.send :set_config_path
|
35
|
-
o.instance_variable_get(:@config
|
33
|
+
o.instance_variable_get(:@cli_options)[:config].should == fixture("options/any-file-name.yml")
|
36
34
|
end
|
37
35
|
|
38
36
|
it "should search for fontcustom.yml if options[:config] is a dir" do
|
39
|
-
|
37
|
+
o = options(
|
40
38
|
:project_root => fixture,
|
41
39
|
:config => "options/config-is-in-dir"
|
42
|
-
|
43
|
-
o = options args
|
40
|
+
)
|
44
41
|
o.send :set_config_path
|
45
|
-
o.instance_variable_get(:@config
|
42
|
+
o.instance_variable_get(:@cli_options)[:config].should == fixture("options/config-is-in-dir/fontcustom.yml")
|
46
43
|
end
|
47
44
|
|
48
45
|
it "should raise error if :config doesn't exist" do
|
49
|
-
|
46
|
+
o = options(
|
50
47
|
:project_root => fixture,
|
51
48
|
:config => "does-not-exist"
|
52
|
-
|
53
|
-
o
|
54
|
-
expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file wasn't found/
|
49
|
+
)
|
50
|
+
expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file/
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
58
54
|
context "when :config is not set" do
|
59
55
|
it "should find fontcustom.yml at :project_root/fontcustom.yml" do
|
60
|
-
|
61
|
-
o = options args
|
56
|
+
o = options :project_root => fixture("options")
|
62
57
|
o.send :set_config_path
|
63
|
-
o.instance_variable_get(:@config
|
58
|
+
o.instance_variable_get(:@cli_options)[:config].should == fixture("options/fontcustom.yml")
|
64
59
|
end
|
65
60
|
|
66
61
|
it "should find fontcustom.yml at :project_root/config/fontcustom.yml" do
|
67
|
-
|
68
|
-
o = options args
|
62
|
+
o = options :project_root => fixture("options/rails-like")
|
69
63
|
o.send :set_config_path
|
70
|
-
o.instance_variable_get(:@config
|
64
|
+
o.instance_variable_get(:@cli_options)[:config].should == fixture("options/rails-like/config/fontcustom.yml")
|
71
65
|
end
|
72
66
|
|
73
67
|
it "should be false if nothing is found" do
|
74
|
-
|
75
|
-
o = options args
|
68
|
+
o = options :project_root => fixture("options/no-config-here")
|
76
69
|
o.send :set_config_path
|
77
|
-
o.instance_variable_get(:@config
|
70
|
+
o.instance_variable_get(:@cli_options)[:config].should == false
|
78
71
|
end
|
79
72
|
end
|
80
73
|
end
|
81
74
|
|
82
75
|
context ".load_config" do
|
83
|
-
|
84
|
-
|
76
|
+
it "should warn if fontcustom.yml is blank" do
|
77
|
+
o = options
|
78
|
+
o.instance_variable_set :@cli_options, {
|
79
|
+
:project_root => fixture,
|
80
|
+
:config => fixture("options/fontcustom-empty.yml")
|
81
|
+
}
|
82
|
+
o.should_receive(:say_message).with :warn, /was empty/
|
83
|
+
o.send :load_config
|
85
84
|
end
|
86
85
|
|
87
86
|
it "should raise error if fontcustom.yml isn't valid" do
|
88
|
-
o = options
|
89
|
-
o.instance_variable_set :@
|
90
|
-
|
87
|
+
o = options
|
88
|
+
o.instance_variable_set :@cli_options, {
|
89
|
+
:project_root => fixture,
|
90
|
+
:config => fixture("options/fontcustom-malformed.yml")
|
91
|
+
}
|
92
|
+
expect { o.send :load_config }.to raise_error Fontcustom::Error, /Error parsing/
|
91
93
|
end
|
92
94
|
|
93
95
|
it "should assign empty hash :config is false" do
|
94
|
-
o = options
|
95
|
-
o.instance_variable_set :@
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
it "should assign empty hash if fontcustom.yml is blank" do
|
101
|
-
o = options args
|
102
|
-
o.instance_variable_set :@config, fixture("options/fontcustom-empty.yml")
|
96
|
+
o = options
|
97
|
+
o.instance_variable_set :@cli_options, {
|
98
|
+
:project_root => fixture,
|
99
|
+
:config => false
|
100
|
+
}
|
103
101
|
o.send :load_config
|
104
102
|
o.instance_variable_get(:@config_options).should == {}
|
105
103
|
end
|
106
104
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
stdout.should match /No configuration/
|
105
|
+
context "when :debug is true" do
|
106
|
+
it "should report which configuration file it's using" do
|
107
|
+
o = options
|
108
|
+
o.instance_variable_set :@cli_options, {
|
109
|
+
:project_root => fixture,
|
110
|
+
:config => fixture("options/any-file-name.yml"),
|
111
|
+
:debug => true
|
112
|
+
}
|
113
|
+
o.should_receive(:say_message).with :debug, /Using settings/
|
114
|
+
o.send :load_config
|
115
|
+
end
|
119
116
|
end
|
120
117
|
end
|
121
118
|
|
122
119
|
context ".merge_options" do
|
123
|
-
|
124
|
-
|
125
|
-
it "should set instance variables for each option key" do
|
126
|
-
o = options
|
127
|
-
o.instance_variable_set :@config_options, {}
|
128
|
-
o.send :merge_options
|
129
|
-
o.send :remove_instance_variable, :@mock_proxy if o.instance_variable_get(:@mock_proxy)
|
130
|
-
o.instance_variables.length.should == Fontcustom::DEFAULT_OPTIONS.length + 1 # @shell
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should overwrite defaults with config file" do
|
120
|
+
it "should overwrite defaults with config options" do
|
134
121
|
o = options
|
135
122
|
o.instance_variable_set :@config_options, { :input => "config" }
|
136
123
|
o.send :merge_options
|
137
|
-
o.
|
124
|
+
o.options[:input].should == "config"
|
138
125
|
end
|
139
126
|
|
140
127
|
it "should overwrite config file and defaults with CLI options" do
|
141
128
|
o = options
|
142
|
-
cli = o.instance_variable_get :@cli_options
|
143
129
|
o.instance_variable_set :@config_options, { :input => "config", :output => "output" }
|
144
|
-
o.instance_variable_set :@cli_options,
|
130
|
+
o.instance_variable_set :@cli_options, { :input => "cli" }
|
145
131
|
o.send :merge_options
|
146
|
-
o.
|
147
|
-
o.
|
132
|
+
o.options[:input].should == "cli"
|
133
|
+
o.options[:output].should == "output"
|
148
134
|
end
|
135
|
+
end
|
149
136
|
|
137
|
+
context ".clean_font_name" do
|
150
138
|
it "should normalize the font name" do
|
151
139
|
o = options
|
152
|
-
o.
|
153
|
-
o.send :
|
154
|
-
o.
|
140
|
+
o.options = { :font_name => " A_stR4nG3 nAm3 Ø& " }
|
141
|
+
o.send :clean_font_name
|
142
|
+
o.options[:font_name].should == "A_stR4nG3--nAm3---"
|
155
143
|
end
|
156
144
|
end
|
157
145
|
|
158
|
-
context ".
|
146
|
+
context ".set_manifest_path" do
|
159
147
|
it "should set :manifest in the config dir by default" do
|
160
|
-
silent
|
161
148
|
o = options
|
162
|
-
o.
|
163
|
-
o.
|
164
|
-
o.
|
165
|
-
|
166
|
-
|
149
|
+
o.options = { :config => "path/to/config/fontcustom.yml" }
|
150
|
+
o.send :set_manifest_path
|
151
|
+
o.options[:manifest].should == "path/to/config/.fontcustom-manifest.json"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should set :manifest in :project_root if :config doesn't exist" do
|
155
|
+
o = options
|
156
|
+
o.options = { :project_root => "project/root" }
|
157
|
+
o.send :set_manifest_path
|
158
|
+
o.options[:manifest].should == "project/root/.fontcustom-manifest.json"
|
167
159
|
end
|
168
160
|
end
|
169
161
|
|
170
|
-
context "
|
162
|
+
context ".set_input_paths" do
|
171
163
|
it "should raise error if input[:vectors] doesn't contain SVGs" do
|
172
164
|
o = options
|
173
|
-
o.
|
174
|
-
|
175
|
-
|
165
|
+
o.options = {
|
166
|
+
:project_root => fixture,
|
167
|
+
:input => "shared/vectors-empty"
|
168
|
+
}
|
176
169
|
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /doesn't contain any SVGs/
|
177
170
|
end
|
178
171
|
|
179
|
-
context "when
|
172
|
+
context "when :input is a hash" do
|
180
173
|
it "should set :templates as :vectors if :templates isn't set" do
|
181
|
-
hash = { :vectors => "shared/vectors" }
|
182
174
|
o = options
|
183
|
-
o.
|
184
|
-
|
185
|
-
|
175
|
+
o.options = {
|
176
|
+
:project_root => fixture,
|
177
|
+
:input => { :vectors => "shared/vectors" }
|
178
|
+
}
|
186
179
|
o.send :set_input_paths
|
187
|
-
input
|
188
|
-
input[:templates].should == fixture("shared/vectors")
|
180
|
+
o.options[:input][:templates].should == fixture("shared/vectors")
|
189
181
|
end
|
190
182
|
|
191
183
|
it "should preserve :templates if it's set" do
|
192
|
-
hash = { :vectors => "shared/vectors", :templates => "shared/templates" }
|
193
184
|
o = options
|
194
|
-
o.
|
195
|
-
|
196
|
-
|
185
|
+
o.options = {
|
186
|
+
:project_root => fixture,
|
187
|
+
:input => { :vectors => "shared/vectors", :templates => "shared/templates" }
|
188
|
+
}
|
197
189
|
o.send :set_input_paths
|
198
|
-
input
|
199
|
-
input[:templates].should == fixture("shared/templates")
|
190
|
+
o.options[:input][:templates].should == fixture("shared/templates")
|
200
191
|
end
|
201
192
|
|
202
193
|
it "should raise an error if :vectors isn't set" do
|
203
|
-
hash = { :templates => "shared/templates" }
|
204
194
|
o = options
|
205
|
-
o.
|
206
|
-
|
207
|
-
|
208
|
-
|
195
|
+
o.options = {
|
196
|
+
:project_root => fixture,
|
197
|
+
:config => "fontcustom.yml",
|
198
|
+
:input => { :templates => "shared/templates" }
|
199
|
+
}
|
200
|
+
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /have a :vectors key/
|
209
201
|
end
|
210
202
|
|
211
203
|
it "should raise an error if :vectors doesn't point to an existing directory" do
|
212
|
-
hash = { :vectors => "shared/not-a-dir" }
|
213
204
|
o = options
|
214
|
-
o.
|
215
|
-
|
216
|
-
|
205
|
+
o.options = {
|
206
|
+
:project_root => fixture,
|
207
|
+
:config => "fontcustom.yml",
|
208
|
+
:input => { :vectors => "shared/not-a-dir" }
|
209
|
+
}
|
217
210
|
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /should be a directory/
|
218
211
|
end
|
219
212
|
end
|
220
213
|
|
221
|
-
context "when
|
214
|
+
context "when :input is a string" do
|
222
215
|
it "should return a hash of locations" do
|
223
216
|
o = options
|
224
|
-
o.
|
225
|
-
|
226
|
-
|
217
|
+
o.options = {
|
218
|
+
:project_root => fixture,
|
219
|
+
:input => "shared/vectors"
|
220
|
+
}
|
227
221
|
o.send :set_input_paths
|
228
|
-
|
229
|
-
input.should have_key(:
|
230
|
-
input.should have_key(:templates)
|
222
|
+
o.options[:input].should have_key(:vectors)
|
223
|
+
o.options[:input].should have_key(:templates)
|
231
224
|
end
|
232
225
|
|
233
226
|
it "should set :templates to match :vectors" do
|
234
227
|
o = options
|
235
|
-
o.
|
236
|
-
|
237
|
-
|
228
|
+
o.options = {
|
229
|
+
:project_root => fixture,
|
230
|
+
:input => "shared/vectors"
|
231
|
+
}
|
238
232
|
o.send :set_input_paths
|
239
|
-
input
|
240
|
-
input[:templates].should == fixture("shared/vectors")
|
233
|
+
o.options[:input][:templates].should == fixture("shared/vectors")
|
241
234
|
end
|
242
235
|
|
243
236
|
it "should raise an error if :vectors doesn't point to a directory" do
|
244
237
|
o = options
|
245
|
-
o.
|
246
|
-
|
247
|
-
|
238
|
+
o.options = {
|
239
|
+
:project_root => fixture,
|
240
|
+
:config => "fontcustom.yml",
|
241
|
+
:input => "shared/not-a-dir"
|
242
|
+
}
|
248
243
|
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /should be a directory/
|
249
244
|
end
|
250
245
|
end
|
251
246
|
end
|
252
247
|
|
253
248
|
context ".set_output_paths" do
|
254
|
-
context "when
|
249
|
+
context "when :output is nil" do
|
255
250
|
it "should default to :project_root/:font_name" do
|
256
|
-
silent
|
257
251
|
o = options
|
258
|
-
o.
|
259
|
-
|
260
|
-
|
261
|
-
|
252
|
+
o.options = {
|
253
|
+
:project_root => fixture,
|
254
|
+
:font_name => "Test-Font"
|
255
|
+
}
|
262
256
|
o.send :set_output_paths
|
263
|
-
output
|
264
|
-
output[:fonts].should == fixture("Test-Font")
|
257
|
+
o.options[:output][:fonts].should == fixture("Test-Font")
|
265
258
|
end
|
266
259
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
260
|
+
context "when :debug is true" do
|
261
|
+
it "should print a warning" do
|
262
|
+
o = options
|
263
|
+
o.options = {
|
264
|
+
:project_root => fixture,
|
265
|
+
:debug => true,
|
266
|
+
:font_name => "Test-Font"
|
267
|
+
}
|
268
|
+
o.should_receive(:say_message).with :debug, /Test-Font/
|
269
|
+
o.send :set_output_paths
|
270
|
+
end
|
275
271
|
end
|
276
272
|
end
|
277
273
|
|
278
|
-
context "when
|
274
|
+
context "when :output is a hash" do
|
279
275
|
it "should set :css and :preview to match :fonts if either aren't set" do
|
280
|
-
hash = { :fonts => "output/fonts" }
|
281
276
|
o = options
|
282
|
-
o.
|
283
|
-
|
284
|
-
|
277
|
+
o.options = {
|
278
|
+
:project_root => fixture,
|
279
|
+
:output => { :fonts => "output/fonts" }
|
280
|
+
}
|
285
281
|
o.send :set_output_paths
|
286
|
-
output
|
287
|
-
output[:
|
288
|
-
output[:preview].should == fixture("output/fonts")
|
282
|
+
o.options[:output][:css].should == fixture("output/fonts")
|
283
|
+
o.options[:output][:preview].should == fixture("output/fonts")
|
289
284
|
end
|
290
285
|
|
291
286
|
it "should preserve :css and :preview if they do exist" do
|
292
|
-
hash = {
|
293
|
-
:fonts => "output/fonts",
|
294
|
-
:css => "output/styles",
|
295
|
-
:preview => "output/preview"
|
296
|
-
}
|
297
287
|
o = options
|
298
|
-
o.
|
299
|
-
|
300
|
-
|
288
|
+
o.options = {
|
289
|
+
:project_root => fixture,
|
290
|
+
:output => {
|
291
|
+
:fonts => "output/fonts",
|
292
|
+
:css => "output/styles",
|
293
|
+
:preview => "output/preview"
|
294
|
+
}
|
295
|
+
}
|
301
296
|
o.send :set_output_paths
|
302
|
-
output
|
303
|
-
output[:
|
304
|
-
output[:preview].should == fixture("output/preview")
|
297
|
+
o.options[:output][:css].should == fixture("output/styles")
|
298
|
+
o.options[:output][:preview].should == fixture("output/preview")
|
305
299
|
end
|
306
300
|
|
307
301
|
it "should create additional paths if they are given" do
|
308
|
-
hash = {
|
309
|
-
:fonts => "output/fonts",
|
310
|
-
"special.js" => "assets/javascripts"
|
311
|
-
}
|
312
302
|
o = options
|
313
|
-
o.
|
314
|
-
|
315
|
-
|
303
|
+
o.options = {
|
304
|
+
:project_root => fixture,
|
305
|
+
:output => {
|
306
|
+
:fonts => "output/fonts",
|
307
|
+
"special.js" => "assets/javascripts"
|
308
|
+
}
|
309
|
+
}
|
316
310
|
o.send :set_output_paths
|
317
|
-
output
|
318
|
-
output[:"special.js"].should == fixture("assets/javascripts")
|
311
|
+
o.options[:output][:"special.js"].should == fixture("assets/javascripts")
|
319
312
|
end
|
320
313
|
|
321
314
|
it "should raise an error if :fonts isn't set" do
|
322
|
-
hash = { :css => "output/styles" }
|
323
315
|
o = options
|
324
|
-
o.
|
325
|
-
|
326
|
-
|
327
|
-
|
316
|
+
o.options = {
|
317
|
+
:project_root => fixture,
|
318
|
+
:config => "fontcustom.yml",
|
319
|
+
:output => { :css => "output/styles" }
|
320
|
+
}
|
321
|
+
expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /have a :fonts key/
|
328
322
|
end
|
329
323
|
end
|
330
324
|
|
331
|
-
context "when
|
325
|
+
context "when :output is a string" do
|
332
326
|
it "should return a hash of output locations" do
|
333
327
|
o = options
|
334
|
-
o.
|
335
|
-
|
336
|
-
|
328
|
+
o.options = {
|
329
|
+
:project_root => fixture,
|
330
|
+
:output => "output/fonts"
|
331
|
+
}
|
337
332
|
o.send :set_output_paths
|
338
|
-
|
339
|
-
output.should
|
340
|
-
output.should have_key(:
|
341
|
-
output.should have_key(:
|
342
|
-
output.should have_key(:preview)
|
333
|
+
o.options[:output].should be_a(Hash)
|
334
|
+
o.options[:output].should have_key(:fonts)
|
335
|
+
o.options[:output].should have_key(:css)
|
336
|
+
o.options[:output].should have_key(:preview)
|
343
337
|
end
|
344
338
|
|
345
339
|
it "should set :css and :preview to match :fonts" do
|
346
340
|
o = options
|
347
|
-
o.
|
348
|
-
|
349
|
-
|
341
|
+
o.options = {
|
342
|
+
:project_root => fixture,
|
343
|
+
:output => "output/fonts"
|
344
|
+
}
|
350
345
|
o.send :set_output_paths
|
351
|
-
output
|
352
|
-
output[:
|
353
|
-
output[:preview].should == fixture("output/fonts")
|
346
|
+
o.options[:output][:css].should == fixture("output/fonts")
|
347
|
+
o.options[:output][:preview].should == fixture("output/fonts")
|
354
348
|
end
|
355
349
|
|
356
350
|
it "should raise an error if :fonts exists but isn't a directory" do
|
357
351
|
o = options
|
358
|
-
o.
|
359
|
-
|
360
|
-
|
361
|
-
|
352
|
+
o.options = {
|
353
|
+
:project_root => fixture,
|
354
|
+
:config => "fontcustom.yml",
|
355
|
+
:output => "shared/not-a-dir"
|
356
|
+
}
|
357
|
+
expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /should be a directory/
|
362
358
|
end
|
363
359
|
end
|
364
360
|
end
|
@@ -366,16 +362,17 @@ describe Fontcustom::Options do
|
|
366
362
|
context ".set_template_paths" do
|
367
363
|
it "should expand shorthand for packaged templates" do
|
368
364
|
o = options
|
369
|
-
o.
|
370
|
-
|
371
|
-
|
372
|
-
|
365
|
+
o.options = {
|
366
|
+
:project_root => fixture,
|
367
|
+
:input => { :templates => "shared/templates" },
|
368
|
+
:templates => %w|preview css scss scss-rails bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss|
|
369
|
+
}
|
373
370
|
o.send :set_template_paths
|
374
|
-
templates
|
375
|
-
templates.should =~ [
|
371
|
+
o.options[:templates].should =~ [
|
376
372
|
File.join(Fontcustom.gem_lib, "templates", "fontcustom-preview.html"),
|
377
373
|
File.join(Fontcustom.gem_lib, "templates", "fontcustom.css"),
|
378
374
|
File.join(Fontcustom.gem_lib, "templates", "_fontcustom.scss"),
|
375
|
+
File.join(Fontcustom.gem_lib, "templates", "_fontcustom-rails.scss"),
|
379
376
|
File.join(Fontcustom.gem_lib, "templates", "fontcustom-bootstrap.css"),
|
380
377
|
File.join(Fontcustom.gem_lib, "templates", "_fontcustom-bootstrap.scss"),
|
381
378
|
File.join(Fontcustom.gem_lib, "templates", "fontcustom-bootstrap-ie7.css"),
|
@@ -385,22 +382,23 @@ describe Fontcustom::Options do
|
|
385
382
|
|
386
383
|
it "should find custom templates in :template_path" do
|
387
384
|
o = options
|
388
|
-
o.
|
389
|
-
|
390
|
-
|
391
|
-
|
385
|
+
o.options = {
|
386
|
+
:project_root => fixture,
|
387
|
+
:input => { :templates => fixture("shared/templates") },
|
388
|
+
:templates => %w|custom.css|
|
389
|
+
}
|
392
390
|
o.send :set_template_paths
|
393
|
-
templates
|
394
|
-
templates.should =~ [fixture("shared/templates/custom.css")]
|
391
|
+
o.options[:templates].should =~ [fixture("shared/templates/custom.css")]
|
395
392
|
end
|
396
393
|
|
397
394
|
it "should raise an error if a template does not exist" do
|
398
395
|
o = options
|
399
|
-
o.
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
396
|
+
o.options = {
|
397
|
+
:project_root => fixture,
|
398
|
+
:input => { :templates => fixture("shared/templates") },
|
399
|
+
:templates => %w|fake-template.txt|
|
400
|
+
}
|
401
|
+
expect { o.send :set_template_paths }.to raise_error Fontcustom::Error, /doesn't exist/
|
404
402
|
end
|
405
403
|
end
|
406
404
|
end
|