Sha256: a535704fd6c230a4a3e81ca58d514884228e13e0d278f2f258a118260bb68f0f

Contents?: true

Size: 1.37 KB

Versions: 11

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk', 'helpers'))

describe '#role?' do
  it 'should accept a role string' do
    lambda { role?('web') }.should.not.raise(ArgumentError)
  end
  
  it 'should require a role string' do
    lambda { role? }.should.raise(ArgumentError)
  end

  it 'should return false if the WD_ROLES environment variable is unset' do
    ENV['WD_ROLES'] = nil
    role?(:web).should.be.false
  end

  it 'should return false if the WD_ROLES environment variable is empty' do
    ENV['WD_ROLES'] = ''
    role?(:web).should.be.false
  end
  
  it 'should return true if the role, as a symbol is among the roles in the WD_ROLES env variable' do
    ENV['WD_ROLES'] = 'db:web'
    role?(:db).should.be.true
  end
  
  it 'should return true if the role, as a string is among the roles in the WD_ROLES env variable' do
    ENV['WD_ROLES'] = 'db:web'
    role?('db').should.be.true
  end
  
  it 'should return false if the role, as a symbol is not among the roles in the WD_ROLES env variable' do
    ENV['WD_ROLES'] = 'db:web'
    role?(:app).should.be.false
  end
  
  it 'should return false if the role, as a string is not among the roles in the WD_ROLES env variable' do
    ENV['WD_ROLES'] = 'db:web'
    role?('app').should.be.false
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
whiskey_disk-0.6.17 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.16 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.15 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.14 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.13 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.12 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.11 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.10 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.4 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.3 spec/whiskey_disk/helpers_spec.rb
whiskey_disk-0.6.2 spec/whiskey_disk/helpers_spec.rb