Sha256: 4fe02673b2a2942e00677eb5de7d161895c2122a62eeb94aec5a8022005bf61b
Contents?: true
Size: 1.78 KB
Versions: 21
Compression:
Stored size: 1.78 KB
Contents
require 'spec_helper' require 'sugar-high/file' 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
21 entries across 21 versions & 1 rubygems