Sha256: 23fd31a8eb0d777b70bdac18da9ff0a870c12e37d4274dc0a9e6654b1b970e8f
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' File.file_mutate :append_content describe FileMutate 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 |
---|---|
file_mutate-0.1.3 | spec/file_mutate/append_content_spec.rb |
file_mutate-0.1.2 | spec/file_mutate/append_content_spec.rb |