Sha256: b575b97c461effaa4f34fa86129a9399d99c05f61dfdcd61b37d24da003fe2f8
Contents?: true
Size: 1.97 KB
Versions: 3
Compression:
Stored size: 1.97 KB
Contents
require 'spec_helper' describe Squall do describe "VERSION" do it "has a valid format" do Squall::VERSION.should match /\d+/ end end describe "#config" do it "yields a configuration with a block" do Squall.should_receive(:config).and_yield(Squall::Config.new) Squall.config { |c| c } end it "returns the config after yield" do Squall.config { |c| c }.should == {} Squall.config.should == {} end it "returns the config without a block" do Squall.config.should == {} end it "sets the base URI" do Squall.config { |c| c.base_uri 'hi'} Squall.config.should_not be_empty Squall.config[:base_uri] == 'hi' end end describe "#reset" do it "resets the configuration to defaults" do default_config Squall.config.should_not be_empty Squall.reset_config Squall.config.should be_empty end end describe "#config_file" do it "defaults to ~/.squall" do file = File.join(ENV['HOME'], '.squall.yml') config = {'username' => 'test', 'password' => 'pass', 'base_uri' => 'http://example.com'} File.stub(:exists?).and_return(true) YAML.should_receive(:load_file).with(file).and_return(config) Squall.configuration_file.should be_nil Squall.config_file Squall.configuration_file.should == file end it "returns an error if the file doesn't exist" do expect { Squall.config_file '/tmp/missing.yml'}.to raise_error(ArgumentError, "Config file doesn't exist '/tmp/missing.yml'") end it "loads the yaml" do File.stub(:exists?).and_return(true) config = {'username' => 'test', 'password' => 'pass', 'base_uri' => 'http://example.com'} YAML.should_receive(:load_file).with('/tmp/exists.yml').and_return(config) Squall.config_file '/tmp/exists.yml' Squall.config.should include(:username => config['username'], :password => config['password'], :base_uri => config['base_uri']) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
squall-1.0.2 | spec/squall_spec.rb |
squall-1.0.1 | spec/squall_spec.rb |
squall-1.0.0 | spec/squall_spec.rb |