Sha256: 33230b51493eb3d36883981d9882f598f779ad7d868ac1a14a035822afb26f69
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' require 'sugar-high/file_mutate' File.mutate_ext :all describe "SugarHigh::File" do let(:empty_file) { fixture_file 'empty.txt' } let(:replace_file) { fixture_file 'file.txt' } describe '#append with :content option' do let(:append_file) { fixture_file 'file.txt' } it 'should append content to existing file - class method' do File.overwrite(append_file) do 'Hello You' end File.append append_file, :content => 'Appended' content = File.read(append_file) content.should match /Hello You/ content.should match /Appended/ end it 'should append content to existing file - instance method' do File.overwrite(append_file) do 'Hello You' end File.new(append_file).append :content => 'Appended' content = File.read(append_file) content.should match /Hello You/ content.should match /Appended/ end end describe '#append with block' do let(:append_file) { fixture_file 'file.txt' } it "should append content to existing file using block arg - class method" do File.overwrite(append_file) do 'Hello You' end File.append append_file do 'Appended' end content = File.read(replace_file) content.should match /Hello You/ content.should match /Appended/ end it "should append content to existing file using block arg - instance method" do File.overwrite(append_file) do 'Hello You' end File.new(append_file).append do 'Appended' end content = File.read(replace_file) content.should match /Hello You/ content.should match /Appended/ end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sugar-high-0.4.4 | spec/sugar-high/file_mutate/append_content_spec.rb |
sugar-high-0.4.3 | spec/sugar-high/file_mutate/append_content_spec.rb |