Sha256: b46ba16c46a2741377d3ca3f3989c94d3ea4db5c9a13c15a6e5eea3cccb3b772

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

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

module RevealCK
  module Changers
    describe StringReplacer do

      describe '.replace!' do

        let :before_replace do
          spec_data 'changers', 'string_replacer', 'before_replace'
        end

        let :after_replace do
          spec_data 'changers', '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'
            StringReplacer.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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reveal-ck-0.2.0 spec/lib/reveal-ck/changers/string_replacer_spec.rb
reveal-ck-0.1.8 spec/lib/reveal-ck/changers/string_replacer_spec.rb
reveal-ck-0.1.7 spec/lib/reveal-ck/changers/string_replacer_spec.rb