Sha256: 8c8147430d35de49eaf2158799c88262d675ac6cae786bbe39c769f2576762a9
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
require 'writer' describe Writer do before :each do Date.stub(:today) do Date.new(2012, 1, 3) end end after :all do cleanup_files end it "creates today's file, blank" do file = Writer.write! file.read.should == "\n" end it "plays well with nils" do file = Writer.write!(nil, nil) file.read.should == "\n" end it "prevents overwriting" do Writer.write! Writer.write! File.open('2012-01Jan-03--2.md') File.open('2012-01Jan-03--3.md') end it "preserves periods" do Writer.write!('some.jquery.file') file = Writer.write!('some.jquery.file') File.basename(file).should == 'some.jquery--2.file' end it "creates the file with your custom name" do filename = "My custom filename.txt" Writer.write!(filename) File.open(filename) end it "uses a template, if it exists" do body = "hello\nworld" Writer.write!('.template', body) Writer.configure do |c| c.template_path = '.template' end file = Writer.write! file.read.should == body + "\n" end end def cleanup_files File.delete('2012-01Jan-03.md') File.delete('2012-01Jan-03--2.md') File.delete('2012-01Jan-03--3.md') File.delete('2012-01Jan-03--4.md') File.delete('2012-01Jan-03--5.md') File.delete('some.jquery.file') File.delete('some.jquery--2.file') File.delete('.template') File.delete('My custom filename.txt') end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
writer-0.1.0 | spec/writer_spec.rb |
writer-0.0.4 | spec/writer_spec.rb |