Sha256: 044a4ebb3dd01b3b80e50cfed1a53525abd46afb879127f0c863170fbe7b489d

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'
require 'goliath/env'

describe Goliath::Env do
  before(:each) do
    @env = Goliath::Env.new
  end

  it 'responds to []=' do
    lambda { @env['test'] = 'blah' }.should_not raise_error
  end

  it 'responds to []' do
    @env['test'] = 'blah'
    lambda { @env['test'].should == 'blah' }.should_not raise_error
  end

  context '#method_missing' do
    it 'allows access to items as methods' do
      @env['db'] = 'test'
      @env.db.should == 'test'
    end

    it 'allows access to config items as methods' do
      @env['config'] = {}
      @env['config']['db'] = 'test'
      @env.db.should == 'test'
    end
  end

  context '#respond_to?' do
    it 'returns true for items in the hash' do
      @env['test'] = 'true'
      @env.respond_to?(:test).should be_true
    end

    it 'returns false for items not in hash' do
      @env.respond_to?(:test).should be_false
    end

    it 'returns true for items in the config hash' do
      @env['config'] = {'test' => true}
      @env.respond_to?(:test).should be_true
    end

    it 'returns false for items not in the config hash' do
      @env['config'] = {}
      @env.respond_to?(:test).should be_false
    end

    it 'delegates if not found' do
      @env.respond_to?(:[]).should be_true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goliath-1.0.4 spec/unit/env_spec.rb
goliath-1.0.3 spec/unit/env_spec.rb
goliath-1.0.2 spec/unit/env_spec.rb
goliath-1.0.1 spec/unit/env_spec.rb
goliath-1.0.0 spec/unit/env_spec.rb
goliath-1.0.0.beta.1 spec/unit/env_spec.rb
goliath-0.9.4 spec/unit/env_spec.rb
goliath-0.9.2 spec/unit/env_spec.rb
goliath-0.9.1 spec/unit/env_spec.rb