spec/fontcustom/utility_spec.rb in fontcustom-1.3.0.beta3 vs spec/fontcustom/utility_spec.rb in fontcustom-1.3.0.beta4

- old
+ new

@@ -1,14 +1,15 @@ require "spec_helper" describe Fontcustom::Utility do class Generator include Fontcustom::Utility - attr_accessor :options + attr_accessor :options, :manifest def initialize - @options = { :project_root => fixture, :quiet => false } + @options = { :quiet => false } + @manifest = fixture ".fontcustom-manifest.json" end end it "should include Thor::Action methods" do gen = Generator.new @@ -38,98 +39,16 @@ hash.foo = "baz" hash.foo.should == "baz" end end - context "#expand_path" do - it "should leave absolute paths alone" do - gen = Generator.new - path = gen.expand_path "/absolute/path" - path.should == "/absolute/path" - end - - it "should prepend paths with :project_root" do - gen = Generator.new - path = gen.expand_path "generators" - path.should == fixture("generators") - end - - it "should follow parent (../../) relative paths" do - gen = Generator.new - gen.options[:project_root] = fixture "shared/vectors" - path = gen.expand_path "../../generators" - path.should == fixture("generators") - end - end - context "#write_file" do it "should replace the contents of a file" do gen = Generator.new file = double "file" File.should_receive(:open).with(fixture("shared/test"), "w").and_yield file file.should_receive(:write).with("testing") gen.write_file fixture("shared/test"), "testing" - end - - #it "should output a message" - end - - #context "#garbage_collect" do - #it "should delete files from passed array" - #it "should update the manifest after completion" - #end - - context "#get_manifest" do - it "should return a manifest hash" do - gen = Generator.new - options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest.json") } - gen.instance_variable_set :@options, options - gen.get_manifest.keys.should == manifest_contents.keys - end - - it "should raise an error if the file is empty" do - gen = Generator.new - options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest-empty.json") } - gen.instance_variable_set :@options, options - expect { gen.get_manifest }.to raise_error Fontcustom::Error, /Couldn't parse/ - end - - it "should raise an error if the file is corrupted" do - gen = Generator.new - options = { :project_root => fixture("generators"), :manifest => fixture("generators/.fontcustom-manifest-corrupted.json") } - gen.instance_variable_set :@options, options - expect { gen.get_manifest }.to raise_error Fontcustom::Error, /Couldn't parse/ - end - end - - #context "#save_manifest" do - #it "should update the manifest" do - #end - #end - - context "#delete_from_manifest" do - it "should empty key from manifest" do - gen = Generator.new - gen.stub :say_changed - manifest = {:fonts => %w|fonts/a.ttf fonts/a.eot fonts/a.woff fonts/a.svg|} - gen.instance_variable_set :@manifest, manifest - gen.should_receive(:save_manifest) - gen.delete_from_manifest :fonts - gen.instance_variable_get(:@manifest)[:fonts].should == [] - end - end - - context "#relative_path" do - it "should trim project root from paths" do - gen = Generator.new - path = gen.relative_path fixture "test/path" - path.should == "test/path" - end - - it "should trim beginning slash" do - gen = Generator.new - path = gen.relative_path "/test/path" - path.should == "test/path" end end #context "#say_message" do #it "should not respond if :quiet is true" do