require 'spec_helper' describe Flombe::Dsl do let(:file) do flombefile <<-G recipe "homebrew" G end let(:flombe) { Flombe::Dsl.evaluate(@file || file) } let(:dna) { JSON.parse(flombe.to_dna) } let(:config) { flombe.config } describe "recipes" do it "should add to the list of recipes" do dna['recipes'].should == ['homebrew'] end end describe "solo.rb configuration" do context "it should let me call chef-solo methods" do Flombe::Dsl::CHEF_METHODS.each do |method| it "can set #{method}" do flombe.send(method, "test") flombe.config[method.to_sym].should == "test" end unless method == "cookbook_path" # we'll test cookbook_path specifically later on end end it "should provide a set of defaults for the solo config" do config[:file_cache_path].should be config[:cookbook_path].should be config[:log_level].should be config[:log_location].should be config[:cache_options].should be end it "should allow overriding of config defaults" do @file = flombefile <<-G log_level :info G config[:log_level].should == :info end end describe "cookbook paths" do let(:default_cookbook) { File.expand_path('../../cookbooks', __FILE__) } it "should include the flombe cookbooks by default" do config[:cookbook_path].should == [default_cookbook] end it "should include the flobme cookbooks even if custom ones are set" do flombe.send(:cookbook_path, "~/my/cookbooks") flombe.config[:cookbook_path].should == [default_cookbook, "~/my/cookbooks"] end it "should allow me to specify multiple cookbook paths" do @file = flombefile <<-G cookbook_path ["~/my/cookbooks", "./local/cookbooks"] G config[:cookbook_path].should == [default_cookbook, "~/my/cookbooks", "./local/cookbooks"] end end describe "recipe config" do it "should store extra params as config options" do @file = flombefile <<-G recipe "mysql", :root_password => 'qit13R', :tmp_path => '/tmp' G dna['mysql'].should == { "root_password" => "qit13R", "tmp_path" => "/tmp" } end end describe "rvm rubies" do let(:file) do flombefile <<-G rubies 'ruby-1.9.2-p180' G end it "should add a ruby intepreter to a list" do dna['rvm']['rubies'].should == ['ruby-1.9.2-p180'] end it "should add the rvm recipe" do dna['recipes'].should include('rvm') end it "should not add the RVM recipe twice" do @file = flombefile <<-G recipe "rvm" rubies 'ruby-1.9.2-p180' G dna['recipes'].should == ['rvm'] end it "should add multiple rubies to a list" do @file = flombefile <<-G rubies ['ruby-1.9.2-p180', 'ruby-1.8.7'] G dna['rvm']['rubies'].should == ['ruby-1.9.2-p180', 'ruby-1.8.7'] end it "should let me define a default ruby" do @file = flombefile <<-G rubies ['ruby-1.9.2-p180', 'ruby-1.8.7'], :default => 'ruby-1.9.2-p180' G dna['rvm']['default_ruby'].should == 'ruby-1.9.2-p180' end end end