Sha256: 3bc0eb4f6fa8dd869c7fed62b2cd39e93c02a689e07972d1da916f58cf303f27
Contents?: true
Size: 953 Bytes
Versions: 1
Compression:
Stored size: 953 Bytes
Contents
require "writer/file_creator" module Writer describe FileCreator do let(:file) { stub(:file) } before :each do File.stub(:open) .with('filename', 'w') .and_yield(file) File.stub(:open) .with('filename', 'r') .and_return(true) end context "with content" do it "writes the content" do file.should_receive(:puts).with('hi') FileCreator.create!('filename', 'hi') end end context "without content" do it "leaves a blank line" do FileCreator.stub(:template) { nil } file.should_receive(:puts).with(nil) FileCreator.create!('filename') end it "uses a template, if it exists" do template = stub(:read => "hello\nworld") FileCreator.stub(:template) { template.read } file.should_receive(:puts).with("hello\nworld") FileCreator.create!('filename') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
writer-0.3.1 | spec/creator_spec.rb |