require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'hx' describe "Hx::Site.load" do it "requires dependencies from the config" do yaml_config = YAML.dump({'require' => ['hx_dummy.rb']}) Hx::Site.load yaml_config, __FILE__ $".should include('hx_dummy.rb') yaml_config = YAML.dump({'require' => 'hx_dummy2.rb'}) Hx::Site.load yaml_config, __FILE__ $".should include('hx_dummy2.rb') end it "returns an Hx::Site object" do yaml_config = YAML.dump({}) site = Hx::Site.load yaml_config, __FILE__ site.should be_an_instance_of(Hx::Site) end it "takes default base_dir from config file path" do yaml_config = YAML.dump({}) site = Hx::Site.load yaml_config, 'foo/baz/config.hx' site.options[:base_dir].should == 'foo/baz' yaml_config = YAML.dump({'options' => {'base_dir' => 'foo/bar'}}) site = Hx::Site.load yaml_config, 'foo/baz/config.hx' site.options[:base_dir].should == 'foo/bar' end it "gets global options from the config, with symbol keys" do input_options = {'foo' => 'bar', 'base_dir' => "xyz"} output_options = {:foo => 'bar', :base_dir => "xyz"} yaml_config = YAML.dump({'options' => input_options}) site = Hx::Site.load yaml_config, __FILE__ site.options[:foo].should == 'bar' site.options[:base_dir].should == 'xyz' end it "creates a source for every entry in sources" do yaml_config = YAML.dump({'sources' => {'foo' => {}, 'bar' => {}}}) site = Hx::Site.load(yaml_config, __FILE__) site.sources.size.should == 2 site.sources.should include('foo') site.sources.should include('bar') end it "creates an output for every entry in outputs" do yaml_config = YAML.dump({'outputs' => [{}, {}]}) site = Hx::Site.load(yaml_config, __FILE__) site.outputs.size.should == 2 end end describe Hx::Site do before(:each) do yaml_config = YAML.dump({}) @site = Hx::Site.load(yaml_config, __FILE__) end it "returns itself from each_entry" do @site.each_entry {}.should == @site end end