Sha256: 24729f6893b54534ca42717c3c170a8a035b7c54c27b4e7cc3b1d11eb09e574a

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

require 'spec_helper'
require 'fileutils'
require 'tmpdir'

module RevealCK

  describe FileStringReplacer do

    describe '.replace!' do

      let :before_replace do
        File.join spec_dir, 'data', 'string_replacer', 'before_replace'
      end

      let :after_replace do
        File.join spec_dir, 'data', 'string_replacer', 'after_replace'
      end

      it 'replaces content within a file' do
        Dir.mktmpdir do |tmp_dir|
          FileUtils.cp before_replace, tmp_dir
          test_file = File.join tmp_dir, 'before_replace'
          FileStringReplacer.replace! test_file, old: ' hideaway at sea', new: 'hh coconuts!'
          test_file_contents = File.open(test_file).read
          after_replace_contents = File.open(after_replace).read
          test_file_contents.should == after_replace_contents
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reveal-ck-0.1.5 spec/lib/reveal-ck/file_string_replacer_spec.rb
reveal-ck-0.1.4 spec/lib/reveal-ck/file_string_replacer_spec.rb
reveal-ck-0.1.3 spec/lib/reveal-ck/file_string_replacer_spec.rb