Sha256: eeacf8fa4f492fa097297787c4bf0df1508e0003c3b3c1f847aa62cbaa9b7982

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

require "#{File.dirname(__FILE__)}/../../../test_helper"

include_fixture_resources

class DirectoryResourceTest < Test::Unit::TestCase
  context "Base" do
    setup do
      PoolParty::Resource.define_resource_methods
      @res = PoolParty::Resources::FileResource.new "/etc/poolparty/lyrics", :content => "I'm just a file, a lonely little file in the world"
      @base = DependencyResolvers::Chef
      @base.compile_directory = test_dir
      @cookboox_directory = test_dir/"cookbooks"/"poolparty"
    end
    
    should "have the template method denoted by has_method_name" do
      str = "template \"/etc/poolparty/lyrics\" do\n  source \"/etc/poolparty/lyrics.erb\"\n  action :create\n  backup 5\n  mode 0644\n  owner \"root\"\nend\n"
      
      assert_equal str, @base.compile(@res)
      assert_equal "I'm just a file, a lonely little file in the world", open(@cookboox_directory/"templates"/"default"/"etc"/"poolparty"/"lyrics.erb").read
    end
    
    should "be able to use a template instead of content" do
      @res.template(fixtures_dir/"templates"/"apache_conf.erb")
      
      @base.compile(@res)
      assert_equal "# Apache conf file\napache <%= cloud.name %>", open(@cookboox_directory/"templates"/"default"/"etc"/"poolparty"/"lyrics.erb").read
    end
    
    should "raise a TemplateNotFoundError if the template cannot be found" do
      PoolParty::PoolPartyError.create("TemplateNotFound")
      assert_raises TemplateNotFound do
        @res.template(fixtures_dir/"templates"/"non_existant_template.erb")
      end
    end
    
  end
  
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.1 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.10 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.11 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.12 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.13 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.2 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.3 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.4 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.5 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.6 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.7 test/lib/poolparty/resources/file_test.rb
auser-poolparty-1.3.8 test/lib/poolparty/resources/file_test.rb
fairchild-poolparty-1.3.5 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.8 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.7 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.6 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.4 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.3 test/lib/poolparty/resources/file_test.rb
poolparty-1.3.1 test/lib/poolparty/resources/file_test.rb