Sha256: 194f09bf62ba62940513f061d4249fb47322ae4ff8ce575578f06e6b7a7fb27f

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe CapistranoProvisioning::User do
  let(:username)      { 'z6MeKbLOXPqi5P' }
  let(:server)        { 'test1.example.com' }
  let(:config_mock)   { mock(Capistrano::Configuration) }
  let(:user)          { CapistranoProvisioning::User.new(:name => username, :server => server, :config => config_mock) }

  describe "install" do
    it "should require a server" do
      expect { user.install }.to raise_error(SystemExit)
    end

    it "should error if the user's ssh key cannot be loaded" do
      expect { user.install(:server => server) }.to raise_error(SystemExit)
    end  
  end
  
  it "should create an account on the server" do      
    config_mock.should_receive(:run).with(/#{username}/, anything()).once
    config_mock.should_receive(:sudo).with(no_args()).once
    
    user.send(:create_account_on_server, server)
  end
  
  describe "and groups" do
    it "should return an empty array if there are no groups" do
      user.groups.should == []
    end
    
    it "should de-duplify groups" do
      user.groups = ['test_group', 'test_group2', 'test_group']
      user.groups.should == ['test_group','test_group2']
    end
    
    it "should add a user to one group" do
      user = CapistranoProvisioning::User.new(:name => username, :server => server, :config => config_mock, :groups => 'test_group')
      user.groups.should include("test_group")
    end
    
    it "should add a user to an array of groups" do
      user = CapistranoProvisioning::User.new(:name => username, :server => server, :config => config_mock, :groups => ['test_group', 'test_group_2'])
      user.groups.should include("test_group")
      user.groups.should include("test_group_2")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
capistrano-provisioning-0.0.8 spec/user_spec.rb
capistrano-provisioning-0.0.7 spec/user_spec.rb
capistrano-provisioning-0.0.6 spec/user_spec.rb
capistrano-provisioning-0.0.4 spec/user_spec.rb
capistrano-provisioning-0.0.3 spec/user_spec.rb