Sha256: 206410bba410e00b3fd589f1d227475d463ca2df0dda590e444a1292ba11edfe

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

def run_command
  eval File.read(File.join(File.dirname(__FILE__), *%w[.. bin wd_role]))
end

describe 'wd role command' do
  before do
    ENV['WD_ROLES'] = nil
  end
  
  describe 'when no command-line arguments are specified' do
    before do
      Object.send(:remove_const, :ARGV)
      ARGV = []
    end  
    
    it 'fails' do
      lambda { run_command }.should.raise(SystemExit)
    end
  end
  
  describe "when a role is specified on the command-line" do
    before do
      Object.send(:remove_const, :ARGV)
      ARGV = ['app']
    end  

    it 'fails when no WD_ROLES environment setting is present' do
      ENV['WD_ROLES'] = nil
      lambda { run_command }.should.raise(SystemExit)
    end
    
    it 'fails when an empty WD_ROLES environment setting is present' do
      ENV['WD_ROLES'] = ''
      lambda { run_command }.should.raise(SystemExit)
    end
    
    it 'fails when the WD_ROLES environment setting does not contain that role' do
      ENV['WD_ROLES'] = 'web:nonapp:db'
      lambda { run_command }.should.raise(SystemExit)
    end
    
    it 'succeeds when the WD_ROLES environment setting contains that role' do
      ENV['WD_ROLES'] = 'web:app:db'
      lambda { run_command }.should.not.raise
    end    
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
ol-whisk_deploy-0.6.25 spec/wd_role_command_spec.rb
ol-whisk_deploy-0.6.26 spec/wd_role_command_spec.rb
whisk_deploy-0.6.26 spec/wd_role_command_spec.rb
whiskey_disk-0.6.24 spec/wd_role_command_spec.rb
whiskey_disk-0.6.23 spec/wd_role_command_spec.rb