Sha256: 6c6609c19653e783cf60c8bd226b5eda86e2019ae231d73b66f25d787511d9c1

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path('../test_helper', __FILE__)

module ReloadDotKick; end

describe "Kicker::Recipes" do
  before do
    Kicker::Recipes.reset!
  end
  
  it "returns a list of recipes" do
    recipe_files = Kicker::Recipes.recipe_files
    if File.exist?(File.expand_path('~/.kick'))
      Set.new(recipe_files).should == Set.new(Dir.glob('../../lib/kicker/recipes/**/*.rb'))
    else
      Dir.glob('../../lib/kicker/recipes/**/*.rb').each do |filename|
        recipe_files.should.include?(filename)
      end
    end
  end
  
  it "returns a list of recipe names" do
    expected = Set.new(%w(could_not_handle_file dot_kick execute_cli_command ignore jstest rails ruby).map { |n| n.to_sym })
    actual = Kicker::Recipes.recipe_names
    if File.exist?(File.expand_path('~/.kick'))
      actual.should == expected
    else
      expected.each do |name|
        actual.should.include?(name)
      end
    end
  end
  
  if File.exist?(File.expand_path('~/.kick'))
    it "should add ~/.kick to the load path" do
      $:.should.include File.expand_path('~/.kick')
    end
  else
    puts "[!] ~/.kick does not exist, not testing the Kicker directory support."
  end
  
  it "should load a recipe" do
    name = Kicker::Recipes.recipe_names.last
    recipe name
  end
  
  it "does not break when a recipe is loaded twice" do
    name = Kicker::Recipes.recipe_names.last
    recipe name
    recipe name
  end
  
  it "should define a recipe load callback" do
    called = false
    recipe('new_recipe') { called = true }
    assert !called
    recipe(:new_recipe)
    assert called
  end
  
  it "should raise if a recipe does not exist" do
    begin
      recipe :foobar
    rescue LoadError => e
      e.message.should.start_with "Can't load recipe `foobar', it doesn't exist on disk."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kicker-2.4.0 test/recipes_test.rb