require 'spec_helper' describe Stackster do before do @config = { 'access_key' => 'the-key', 'secret_key' => 'secret', 'region' => 'us-west-1' } end it "should create a new config object from the hash passed as config" do config = Stackster::Config.new :config => @config config.access_key.should == @config['access_key'] config.secret_key.should == @config['secret_key'] config.region.should == @config['region'] end it "should create a new config object and read from ~/.stackster.yml" do File.should_receive(:open).with("#{ENV['HOME']}/.stackster.yml"). and_return(@config.to_yaml) config = Stackster::Config.new config.access_key.should == @config['access_key'] config.secret_key.should == @config['secret_key'] config.region.should == @config['region'] end it "should create a new logger when one is not specified" do config = Stackster::Config.new :config => @config config.logger.class.should == Stackster::StacksterLogger end it "should accept a logger passed as :logger" do config = Stackster::Config.new :config => @config, :logger => 'the-logger' config.logger.should == 'the-logger' end end