Sha256: f1589a100d50a4362c70b47b43197ba6b595f662cf0f90df41d848873b24e3c6

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe "AppSent.init" do

  before :each do
    @right_params = { :path => 'fixtures', :env => 'test' }
    @fixtures_path = File.expand_path(File.join(File.dirname(__FILE__),'fixtures'))
  end

  it "should require config path" do
    @right_params.delete(:path)
    expect { AppSent.init(@right_params) do; end }.to raise_exception(AppSent::ConfigPathNotSet)
  end

  it "should require environment variable" do
    @right_params.delete(:env)
    expect { AppSent.init(@right_params) do; end }.to raise_exception(AppSent::EnvironmentNotSet)
  end

  it "should require block" do
    expect { AppSent.init(@right_params) }.to raise_exception(AppSent::BlockRequired)
  end

  it "should save config path to @@config_path" do
    AppSent.init(@right_params) do; end
    AppSent.config_path.should eq(@fixtures_path)
  end

  it "should save environment to @@environment" do
    AppSent.init(@right_params) do; end
    AppSent.send(:class_variable_get,:@@environment).should eq('test')
  end

  it "should save array of configs to @@configs" do
    expect {
      AppSent.init(@right_params) do
	config1
	config2
	config3
      end
    }.to raise_exception(AppSent::Error)
    AppSent.config_files.should eq(%w(config1 config2 config3))
  end

  it "should create corresponding constants with values" do
    AppSent.init(@right_params) do
      simple_config
      database do
	username :type => String
	password :type => String
	port     :type => Fixnum
      end

      simple_config_with_just_type :type => Array
    end

    AppSent::SIMPLE_CONFIG.should eq({:a=>1, :b=>'2'})
    AppSent::DATABASE.should eq({:username => 'user', :password => 'pass', :port => 100500})
    AppSent::SIMPLE_CONFIG_WITH_JUST_TYPE.should eq([1,2,3])
  end

end

describe 'AppSent.new' do

  subject { AppSent.new }

  %w(all_valid? load! full_error_message).each do |method|
    it { should respond_to(method) }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appsent-0.0.3 spec/dsl_spec.rb
appsent-0.0.2 spec/dsl_spec.rb
appsent-0.0.1 spec/dsl_spec.rb