Sha256: 867cf96d3840dc7ff9805c469c0ea286c69bec68f6512169a3d7e01b4f4a50fb

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")

describe "AutomateIt::TemplateManager::ERB" do
  before(:all) do
    @a = AutomateIt.new(:verbosity => Logger::WARN)
    @m = @a.template_manager
    @d = @m[:erb]
    @d.setup(:default_check => :mtime)
    @d.available?.should be_true
  end

  before(:each) do
    @a.preview = false
  end

  it "should set file's mode when rendering" do
    @a.mktempdircd do
      source = "foo"
      target = "bar"
      mode1 = 0646 if INTERPRETER.shell_manager.provides_mode?
      mode2 = 0100646
      File.open(source, "w+"){|h| h.write("<%=variable%>")}

      opts = {:file => source, :to => target, :locals => {:variable => 42}}
      opts[:mode] = mode1 if mode1
      @a.render(opts).should be_true
      File.read(target).should == "42"
      if INTERPRETER.shell_manager.provides_mode?
        File.stat(target).mode.should == mode2
      else
        puts "NOTE: Can't check permission modes on this platform, #{__FILE__}"
      end
    end
  end

  it "should fail to render non-existent file" do
    @a.mktempdircd do
      lambda { @a.render(:file => "foo", :to => "bar") }.should raise_error(Errno::ENOENT)
    end
  end

  it "should not raise error with non-existent file in preview mode" do
    @a.mktempdircd do
      @a.preview = true
      @a.render(:file => "foo", :to => "bar").should be_true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
automateit-0.70928 spec/integration/template_manager_erb_spec.rb
automateit-0.70930 spec/integration/template_manager_erb_spec.rb
automateit-0.71003 spec/integration/template_manager_erb_spec.rb
automateit-0.71006 spec/integration/template_manager_erb_spec.rb