Sha256: 0f86531059005fb92b0b0808a64abffb0ee1318f179a24aca0f51298c144878e

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
File.file_mutate :replace_content

describe FileMutate do
  let(:empty_file)      { fixture_file 'empty.txt' }
  let(:non_empty_file)  { fixture_file 'non-empty.txt'}
  let(:class_file)      { fixture_file 'class_file.rb'}
  let(:replace_file)    { fixture_file 'file.txt' }
  let(:file_to_delete)  { fixture_file 'file_to_delete.txt' }
  let(:routes_file)     { fixture_file 'routes_file.rb' }
  let(:app_file)        { fixture_file 'application_file.rb' }

  describe '#replace_content_from' do
    let(:replace_file)    { fixture_file 'file.txt' }

    it "should replace content from existing file - class method" do
      File.overwrite(replace_file) do
        'Hello You'
      end
      File.replace_content_from replace_file, :where => 'You', :with => 'Me'
      File.read(replace_file).should_not match /You/
    end

    it 'should remove content from existing file - instance method #replace_content' do
      File.overwrite(replace_file) do
        'Hello You'
      end
      File.new(replace_file).replace_content :where => 'You', :with => 'Me'
      File.read(replace_file).should_not match /You/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
file_mutate-0.1.3 spec/file_mutate/replace_content_spec.rb
file_mutate-0.1.2 spec/file_mutate/replace_content_spec.rb