Sha256: 094330ccaa56820ad5dfb512dd1a1a17a5f026893e33be00a96a304ef54c30e3

Contents?: true

Size: 1.19 KB

Versions: 23

Compression:

Stored size: 1.19 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(: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

23 entries across 23 versions & 1 rubygems

Version Path
sugar-high-0.5.5 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.5.4 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.5.3 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.5.1 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.5.0 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.9.5 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.9.3 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.9.2 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.9.1 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.9 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.8 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.7 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.6.4 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.6.3 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.6.2 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.6.1 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.6 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.5.2 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.5 spec/sugar-high/file_mutate/replace_content_spec.rb
sugar-high-0.4.4.2 spec/sugar-high/file_mutate/replace_content_spec.rb