Sha256: 22e737a4181d64e926aa6fd66da3a731d15624195ec8fe711cd78bb684d35b5d

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 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

1 entries across 1 versions & 1 rubygems

Version Path
reveal-ck-0.1.6 spec/lib/reveal-ck/file_string_replacer_spec.rb