Sha256: 4412b3f8416911b7522ccb19c1f33baa90d3bc8e2e4d67f27719e25063062b3a

Contents?: true

Size: 1.27 KB

Versions: 21

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe Hobo::Lib::Seed::Replacer do
  before do
    FakeFS.activate!
    Dir.mkdir("bin")
    Dir.mkdir("dir")
    {
      "./test1" => "some {{test}} is here",
      "./test2" => "no test is here",
      "./dir/test" => "subdir {{test}}",
      "./dir/nested" => "nested {{nested.test}}",
      "./dir/no-utf" => "\xc2 {{test}}", # invalid utf should be skipped
      "./bin/test" => "{{test}}" # bin/ should be ignored
    }.each do |name, content|
      File.write(name, content)
    end

    @replacer = Hobo::Lib::Seed::Replacer.new
  end

  after do
    FakeFS::FileSystem.clear
    FakeFS.deactivate!
  end

  it "should respect exclude directories" do
    files = @replacer.replace(".", { :test => 'badger' })
    File.read("./bin/test").should eq "{{test}}"
  end

  it "should replace placeholders in files" do
    files = @replacer.replace(".", { :test => 'badger' })
    expect(files.sort).to eq(["./dir/test", "./test1"])

    File.read("./test1").should eq "some badger is here"
    File.read("./dir/test").should eq "subdir badger"
  end

  it "should handle nested hashes" do
    files = @replacer.replace(".", { :nested => { :test => 'nested' } })
    expect(files.sort).to eq(["./dir/nested"])

    File.read("./dir/nested").should eq "nested nested"
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.15 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.14 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.13 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.11 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc11 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc10 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc9 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc8 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc7 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc6 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc4 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.10.pre.rc2 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.9 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.9.pre.rc2 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.9.pre.rc1 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.9.pre.alpha spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.8 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.7.pre.rc3 spec/hobo/lib/seed/replacer_spec.rb
hobo-inviqa-0.0.7.pre.rc2 spec/hobo/lib/seed/replacer_spec.rb