Top Level Namespace

Defined Under Namespace

Modules: OwncloudCookbook Classes: FakeRecipe

Instance Method Summary collapse

Instance Method Details

#centos?Boolean

Checks if we are on CentOS.

Examples:

centos? #=> true

28
29
30
# File 'test/integration/postgresql/serverspec/postgresql_spec.rb', line 28

def centos?
  File.exist?('/etc/centos-release')
end

#getconf(var) ⇒ String

Query system configuration variables.

Examples:

getconf('PAGE_SIZE') #=> 4096

28
29
30
31
32
# File 'test/cookbooks/owncloud_test/recipes/postgresql_memory.rb', line 28

def getconf(var)
  cmd = Mixlib::ShellOut.new("getconf #{var}").run_command
  cmd.error!
  cmd.stdout.split("\n")[-1]
end

#start_mysql_service(resource_name) ⇒ Object

ChefSpec matcher for MySQL services :start action.

Examples:

expect(chef_run).to start_mysql_service('default')

27
28
29
30
31
# File 'test/unit/support/matchers.rb', line 27

def start_mysql_service(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(
    :mysql_service, :start, resource_name
  )
end

#stub_apache2_cookbookObject

ChefSpec stubs for apache2 cookbook.

Examples:

describe 'mycookbook::default' do
  let(:chef_runner) { ChefSpec::SoloRunner.new }
  let(:chef_run) { chef_runner.converge(described_recipe) }
  before { stub_apache2_cookbook }
  # [...]
end

31
32
33
34
35
# File 'test/unit/support/cookbook_stubs.rb', line 31

def stub_apache2_cookbook
  stub_command('/usr/sbin/apache2 -t').and_return(true)
  stub_command('/usr/sbin/httpd -t').and_return(true)
  stub_command('which php').and_return(true)
end

#stub_nginx_cookbookObject

ChefSpec stubs for nginx cookbook.

Examples:

describe 'mycookbook::default' do
  let(:chef_runner) { ChefSpec::SoloRunner.new }
  let(:chef_run) { chef_runner.converge(described_recipe) }
  before { stub_nginx_cookbook }
  # [...]
end

65
66
67
68
69
# File 'test/unit/support/cookbook_stubs.rb', line 65

def stub_nginx_cookbook
  stub_php_fpm_cookbook
  stub_command('which nginx').and_return(true)
  allow(::File).to receive(:symlink?).and_call_original
end

#stub_php_fpm_cookbookObject

ChefSpec stubs for php-fpm cookbook.

Examples:

describe 'mycookbook::default' do
  let(:chef_runner) { ChefSpec::SoloRunner.new }
  let(:chef_run) { chef_runner.converge(described_recipe) }
  before { stub_php_fpm_cookbook }
  # [...]
end

47
48
49
50
51
52
53
# File 'test/unit/support/cookbook_stubs.rb', line 47

def stub_php_fpm_cookbook
  stub_command(
    'test -d /etc/php5/fpm/pool.d || mkdir -p /etc/php5/fpm/pool.d'
  ).and_return(true)
  stub_command('test -d /etc/php-fpm.d || mkdir -p /etc/php-fpm.d')
    .and_return(true)
end

#stub_postfix_cookbookObject

ChefSpec stubs for postfix cookbook.

Examples:

describe 'mycookbook::default' do
  let(:chef_runner) { ChefSpec::SoloRunner.new }
  let(:chef_run) { chef_runner.converge(described_recipe) }
  before { stub_postfix_cookbook }
  # [...]
end

103
104
105
106
107
# File 'test/unit/support/cookbook_stubs.rb', line 103

def stub_postfix_cookbook
  stub_command(
    '/usr/bin/test /etc/alternatives/mta -ef /usr/sbin/sendmail.postfix'
  ).and_return(true)
end

#stub_postgresql_cookbookObject

ChefSpec stubs for postgresql cookbook.

Examples:

describe 'mycookbook::default' do
  let(:chef_runner) { ChefSpec::SoloRunner.new }
  let(:chef_run) { chef_runner.converge(described_recipe) }
  before { stub_postgresql_cookbook }
  # [...]
end

81
82
83
84
85
86
87
88
89
90
91
# File 'test/unit/support/cookbook_stubs.rb', line 81

def stub_postgresql_cookbook
  stub_command(
    "psql -c 'SELECT lanname FROM pg_catalog.pg_language' #{db_name} "\
    "| grep '^ plpgsql$'"
  ).and_return(false)

  stub_command('ls /recovery.conf').and_return(false)
  stub_command('ls /var/lib/pgsql/data/recovery.conf').and_return(true)
  stub_command('ls /var/lib/postgresql/9.1/main/recovery.conf')
    .and_return(true)
end