fontcustom 1.3.0.beta3 → 1.3.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,10 +3,11 @@ require "spec_helper"
3
3
  describe Fontcustom::Utility do
4
4
  class Generator
5
5
  include Fontcustom::Utility
6
- attr_accessor :options
6
+ attr_accessor :options, :manifest
7
7
 
8
8
  def initialize
9
- @options = { :project_root => fixture, :quiet => false }
9
+ @options = { :quiet => false }
10
+ @manifest = fixture ".fontcustom-manifest.json"
10
11
  end
11
12
  end
12
13
 
@@ -40,27 +41,6 @@ describe Fontcustom::Utility do
40
41
  end
41
42
  end
42
43
 
43
- context "#expand_path" do
44
- it "should leave absolute paths alone" do
45
- gen = Generator.new
46
- path = gen.expand_path "/absolute/path"
47
- path.should == "/absolute/path"
48
- end
49
-
50
- it "should prepend paths with :project_root" do
51
- gen = Generator.new
52
- path = gen.expand_path "generators"
53
- path.should == fixture("generators")
54
- end
55
-
56
- it "should follow parent (../../) relative paths" do
57
- gen = Generator.new
58
- gen.options[:project_root] = fixture "shared/vectors"
59
- path = gen.expand_path "../../generators"
60
- path.should == fixture("generators")
61
- end
62
- end
63
-
64
44
  context "#write_file" do
65
45
  it "should replace the contents of a file" do
66
46
  gen = Generator.new
@@ -69,67 +49,6 @@ describe Fontcustom::Utility do
69
49
  file.should_receive(:write).with("testing")
70
50
  gen.write_file fixture("shared/test"), "testing"
71
51
  end
72
-
73
- #it "should output a message"
74
- end
75
-
76
- #context "#garbage_collect" do
77
- #it "should delete files from passed array"
78
- #it "should update the manifest after completion"
79
- #end
80
-
81
- context "#get_manifest" do
82
- it "should return a manifest hash" do
83
- gen = Generator.new
84
- options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest.json") }
85
- gen.instance_variable_set :@options, options
86
- gen.get_manifest.keys.should == manifest_contents.keys
87
- end
88
-
89
- it "should raise an error if the file is empty" do
90
- gen = Generator.new
91
- options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest-empty.json") }
92
- gen.instance_variable_set :@options, options
93
- expect { gen.get_manifest }.to raise_error Fontcustom::Error, /Couldn't parse/
94
- end
95
-
96
- it "should raise an error if the file is corrupted" do
97
- gen = Generator.new
98
- options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest-corrupted.json") }
99
- gen.instance_variable_set :@options, options
100
- expect { gen.get_manifest }.to raise_error Fontcustom::Error, /Couldn't parse/
101
- end
102
- end
103
-
104
- #context "#save_manifest" do
105
- #it "should update the manifest" do
106
- #end
107
- #end
108
-
109
- context "#delete_from_manifest" do
110
- it "should empty key from manifest" do
111
- gen = Generator.new
112
- gen.stub :say_changed
113
- manifest = {:fonts => %w|fonts/a.ttf fonts/a.eot fonts/a.woff fonts/a.svg|}
114
- gen.instance_variable_set :@manifest, manifest
115
- gen.should_receive(:save_manifest)
116
- gen.delete_from_manifest :fonts
117
- gen.instance_variable_get(:@manifest)[:fonts].should == []
118
- end
119
- end
120
-
121
- context "#relative_path" do
122
- it "should trim project root from paths" do
123
- gen = Generator.new
124
- path = gen.relative_path fixture "test/path"
125
- path.should == "test/path"
126
- end
127
-
128
- it "should trim beginning slash" do
129
- gen = Generator.new
130
- path = gen.relative_path "/test/path"
131
- path.should == "test/path"
132
- end
133
52
  end
134
53
 
135
54
  #context "#say_message" do
@@ -78,24 +78,21 @@ RSpec.configure do |c|
78
78
  result
79
79
  end
80
80
 
81
- def live_test(cleanup = true)
81
+ def live_test
82
82
  testdir = fixture File.join("sandbox", "test")
83
- begin
84
- FileUtils.mkdir testdir
85
- FileUtils.cp_r fixture("shared/vectors"), testdir
86
- FileUtils.cd testdir do
87
- yield(testdir)
88
- end
89
- ensure
90
- FileUtils.rm_r testdir if cleanup
83
+ FileUtils.rm_r testdir
84
+ FileUtils.mkdir testdir
85
+ FileUtils.cp_r fixture("shared/vectors"), testdir
86
+ FileUtils.cd testdir do
87
+ yield(testdir)
91
88
  end
92
89
  end
93
90
 
94
- def test_manifest(options = {:input => fixture("shared/vectors"), :quiet => true})
91
+ def test_manifest(options = { :input => "vectors", :quiet => true })
95
92
  base = Fontcustom::Base.new options
96
93
  manifest = base.instance_variable_get :@manifest
97
- manifest[:checksum] = {:current => base.send(:checksum), :previous => ""}
98
- base.save_manifest
99
- base.instance_variable_get(:@options)[:manifest]
94
+ checksum = base.send :checksum
95
+ manifest.set :checksum, { :current => checksum, :previous => "" }
96
+ manifest
100
97
  end
101
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontcustom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.beta3
4
+ version: 1.3.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Zau
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-01 00:00:00.000000000 Z
12
+ date: 2013-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json