fontcustom 1.2.0 → 1.3.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +16 -0
  3. data/CONTRIBUTING.md +35 -15
  4. data/TODO.md +20 -0
  5. data/lib/fontcustom.rb +11 -24
  6. data/lib/fontcustom/base.rb +56 -0
  7. data/lib/fontcustom/cli.rb +13 -12
  8. data/lib/fontcustom/generator/font.rb +63 -65
  9. data/lib/fontcustom/generator/template.rb +81 -52
  10. data/lib/fontcustom/manifest.rb +42 -0
  11. data/lib/fontcustom/options.rb +93 -80
  12. data/lib/fontcustom/scripts/generate.py +116 -127
  13. data/lib/fontcustom/templates/_fontcustom-rails.scss +13 -18
  14. data/lib/fontcustom/templates/_fontcustom.scss +10 -18
  15. data/lib/fontcustom/templates/fontcustom-preview.html +17 -24
  16. data/lib/fontcustom/templates/fontcustom.css +10 -18
  17. data/lib/fontcustom/templates/fontcustom.yml +3 -3
  18. data/lib/fontcustom/utility.rb +145 -0
  19. data/lib/fontcustom/version.rb +1 -1
  20. data/lib/fontcustom/watcher.rb +1 -1
  21. data/spec/fixtures/generators/.fontcustom-manifest-corrupted.json +12 -5
  22. data/spec/fixtures/generators/.fontcustom-manifest-empty.json +0 -0
  23. data/spec/fixtures/generators/.fontcustom-manifest.json +49 -14
  24. data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.eot +0 -0
  25. data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.svg +56 -0
  26. data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.ttf +0 -0
  27. data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.woff +0 -0
  28. data/spec/fixtures/sandbox/.gitkeep +0 -0
  29. data/spec/fontcustom/base_spec.rb +58 -0
  30. data/spec/fontcustom/cli_spec.rb +15 -0
  31. data/spec/fontcustom/generator/font_spec.rb +50 -220
  32. data/spec/fontcustom/generator/template_spec.rb +30 -194
  33. data/spec/fontcustom/generator/template_spec.rb.off +215 -0
  34. data/spec/fontcustom/manifest_spec.rb +16 -0
  35. data/spec/fontcustom/options_spec.rb +206 -208
  36. data/spec/fontcustom/utility_spec.rb +163 -0
  37. data/spec/fontcustom/{watcher_spec.rb → watcher_spec.rb.off} +0 -0
  38. data/spec/spec_helper.rb +77 -19
  39. metadata +44 -54
  40. data/lib/fontcustom/templates/_fontcustom-bootstrap-ie7.scss +0 -22
  41. data/lib/fontcustom/templates/_fontcustom-bootstrap.scss +0 -63
  42. data/lib/fontcustom/templates/fontcustom-bootstrap-ie7.css +0 -22
  43. data/lib/fontcustom/templates/fontcustom-bootstrap.css +0 -63
  44. data/lib/fontcustom/util.rb +0 -62
  45. data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
  46. data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +0 -102
  47. data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
  48. data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
  49. 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 'spec_helper'
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
- def silent
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
- before(:each) { Fontcustom::Options.any_instance.stub(:set_options) }
14
-
15
- context "#initialize" do
14
+ context ".overwrite_examples" do
16
15
  it "should overwite example defaults with real defaults" do
17
- # imitates the default hash passed by thor
18
- options = Fontcustom::Options.new(Fontcustom::EXAMPLE_OPTIONS.dup)
19
- options = options.instance_variable_get(:@cli_options)
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
- options[key].should == Fontcustom::DEFAULT_OPTIONS[key]
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
- args = {
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).should == fixture("options/any-file-name.yml")
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
- args = {
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).should == fixture("options/config-is-in-dir/fontcustom.yml")
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
- args = {
46
+ o = options(
50
47
  :project_root => fixture,
51
48
  :config => "does-not-exist"
52
- }
53
- o = options args
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
- args = { :project_root => fixture("options") }
61
- o = options args
56
+ o = options :project_root => fixture("options")
62
57
  o.send :set_config_path
63
- o.instance_variable_get(:@config).should == fixture("options/fontcustom.yml")
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
- args = { :project_root => fixture("options/rails-like") }
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).should == fixture("options/rails-like/config/fontcustom.yml")
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
- args = { :project_root => fixture("options/no-config-here") }
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).should == false
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
- def args
84
- { :project_root => fixture, :quiet => true }
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 args
89
- o.instance_variable_set :@config, fixture("options/fontcustom-malformed.yml")
90
- expect { o.send :load_config }.to raise_error Fontcustom::Error, /failed to load/
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 args
95
- o.instance_variable_set :@config, false
96
- o.send :load_config
97
- o.instance_variable_get(:@config_options).should == {}
98
- end
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
- it "should report which configuration file it's using" do
108
- o = options
109
- o.instance_variable_set :@config, fixture("options/any-file-name.yml")
110
- stdout = capture(:stdout) { o.send :load_config }
111
- stdout.should match /options\/any-file-name\.yml/
112
- end
113
-
114
- it "should warn if no configuration file is used" do
115
- o = options
116
- o.instance_variable_set :@config, false
117
- stdout = capture(:stdout) { o.send :load_config }
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
- before(:each) { silent }
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.instance_variable_get(:@input).should == "config"
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, cli.merge( :input => "cli" )
130
+ o.instance_variable_set :@cli_options, { :input => "cli" }
145
131
  o.send :merge_options
146
- o.instance_variable_get(:@input).should == "cli"
147
- o.instance_variable_get(:@output).should == "output"
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.instance_variable_set :@config_options, { :input => "config", :font_name => " A_stR4nG3 nAm3 Ø& " }
153
- o.send :merge_options
154
- o.instance_variable_get(:@font_name).should == "A_stR4nG3--nAm3---"
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 ".set_data_path" do
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.instance_variable_set :@config, "path/to/config/fontcustom.yml"
163
- o.instance_variable_set :@manifest, nil
164
- o.send :remove_instance_variable, :@cli_options
165
- o.send :set_data_path
166
- o.instance_variable_get(:@manifest).should == "path/to/config/.fontcustom-manifest.json"
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 "#send :set_input_paths" do
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.instance_variable_set :@project_root, fixture
174
- o.instance_variable_set :@input, "shared/vectors-empty"
175
- o.send :remove_instance_variable, :@cli_options
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 @input is a hash" do
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.instance_variable_set :@project_root, fixture
184
- o.instance_variable_set :@input, hash
185
- o.send :remove_instance_variable, :@cli_options
175
+ o.options = {
176
+ :project_root => fixture,
177
+ :input => { :vectors => "shared/vectors" }
178
+ }
186
179
  o.send :set_input_paths
187
- input = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
195
- o.instance_variable_set :@input, hash
196
- o.send :remove_instance_variable, :@cli_options
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 = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
206
- o.instance_variable_set :@input, hash
207
- o.send :remove_instance_variable, :@cli_options
208
- expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /contain a :vectors key/
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.instance_variable_set :@project_root, fixture
215
- o.instance_variable_set :@input, hash
216
- o.send :remove_instance_variable, :@cli_options
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 @input is a string" do
214
+ context "when :input is a string" do
222
215
  it "should return a hash of locations" do
223
216
  o = options
224
- o.instance_variable_set :@project_root, fixture
225
- o.instance_variable_set :@input, "shared/vectors"
226
- o.send :remove_instance_variable, :@cli_options
217
+ o.options = {
218
+ :project_root => fixture,
219
+ :input => "shared/vectors"
220
+ }
227
221
  o.send :set_input_paths
228
- input = o.instance_variable_get :@input
229
- input.should have_key(:vectors)
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.instance_variable_set :@project_root, fixture
236
- o.instance_variable_set :@input, "shared/vectors"
237
- o.send :remove_instance_variable, :@cli_options
228
+ o.options = {
229
+ :project_root => fixture,
230
+ :input => "shared/vectors"
231
+ }
238
232
  o.send :set_input_paths
239
- input = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
246
- o.instance_variable_set :@input, "shared/not-a-dir"
247
- o.send :remove_instance_variable, :@cli_options
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 @output is nil" do
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.instance_variable_set :@project_root, fixture
259
- o.instance_variable_set :@font_name, "Test-Font"
260
- o.instance_variable_set :@output, nil
261
- o.send :remove_instance_variable, :@cli_options
252
+ o.options = {
253
+ :project_root => fixture,
254
+ :font_name => "Test-Font"
255
+ }
262
256
  o.send :set_output_paths
263
- output = o.instance_variable_get :@output
264
- output[:fonts].should == fixture("Test-Font")
257
+ o.options[:output][:fonts].should == fixture("Test-Font")
265
258
  end
266
259
 
267
- it "should print a warning" do
268
- o = options
269
- o.instance_variable_set :@project_root, fixture
270
- o.instance_variable_set :@font_name, "Test-Font"
271
- o.instance_variable_set :@output, nil
272
- o.send :remove_instance_variable, :@cli_options
273
- stdout = capture(:stdout) { o.send :set_output_paths }
274
- stdout.should match("Test-Font")
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 @output is a hash" do
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.instance_variable_set :@project_root, fixture
283
- o.instance_variable_set :@output, hash
284
- o.send :remove_instance_variable, :@cli_options
277
+ o.options = {
278
+ :project_root => fixture,
279
+ :output => { :fonts => "output/fonts" }
280
+ }
285
281
  o.send :set_output_paths
286
- output = o.instance_variable_get :@output
287
- output[:css].should == fixture("output/fonts")
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.instance_variable_set :@project_root, fixture
299
- o.instance_variable_set :@output, hash
300
- o.send :remove_instance_variable, :@cli_options
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 = o.instance_variable_get :@output
303
- output[:css].should == fixture("output/styles")
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.instance_variable_set :@project_root, fixture
314
- o.instance_variable_set :@output, hash
315
- o.send :remove_instance_variable, :@cli_options
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 = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
325
- o.instance_variable_set :@output, hash
326
- o.send :remove_instance_variable, :@cli_options
327
- expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /contain a :fonts key/
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 @output is a string" do
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.instance_variable_set :@project_root, fixture
335
- o.instance_variable_set :@output, "output/fonts"
336
- o.send :remove_instance_variable, :@cli_options
328
+ o.options = {
329
+ :project_root => fixture,
330
+ :output => "output/fonts"
331
+ }
337
332
  o.send :set_output_paths
338
- output = o.instance_variable_get :@output
339
- output.should be_a(Hash)
340
- output.should have_key(:fonts)
341
- output.should have_key(:css)
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.instance_variable_set :@project_root, fixture
348
- o.instance_variable_set :@output, "output/fonts"
349
- o.send :remove_instance_variable, :@cli_options
341
+ o.options = {
342
+ :project_root => fixture,
343
+ :output => "output/fonts"
344
+ }
350
345
  o.send :set_output_paths
351
- output = o.instance_variable_get :@output
352
- output[:css].should == fixture("output/fonts")
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.instance_variable_set :@project_root, fixture
359
- o.instance_variable_set :@output, "shared/not-a-dir"
360
- o.send :remove_instance_variable, :@cli_options
361
- expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /directory, not a file/
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.instance_variable_set :@project_root, fixture
370
- o.instance_variable_set :@input, { :templates => "shared/templates" }
371
- o.instance_variable_set :@templates, %w|preview css scss bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss|
372
- o.send :remove_instance_variable, :@cli_options
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 = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
389
- o.instance_variable_set :@input, { :templates => fixture("shared/templates") }
390
- o.instance_variable_set :@templates, %w|custom.css|
391
- o.send :remove_instance_variable, :@cli_options
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 = o.instance_variable_get :@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.instance_variable_set :@project_root, fixture
400
- o.instance_variable_set :@input, { :templates => "shared/templates" }
401
- o.instance_variable_set :@templates, %w|fake-template.txt|
402
- o.send :remove_instance_variable, :@cli_options
403
- expect { o.send :set_template_paths }.to raise_error Fontcustom::Error, /does not exist/
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