master
 1describe "stronglifters::postgres" do
 2  subject do
 3    ChefSpec::SoloRunner.new do |node|
 4      node.set["postgres"]["database"] = database_name
 5      node.set["postgres"]["host"] = database_host
 6      node.set["postgres"]["username"] = database_user
 7      node.set["postgresql"]["password"]['postgres'] = database_password
 8      node.set["postgresql"]["config"] = {}
 9      node.set['postgresql']['client']['packages'] = []
10      node.set['postgresql']['config']['data_directory'] = "/var/data"
11      node.set['postgresql']['contrib']['packages'] = []
12    end.converge(described_recipe)
13  end
14
15  let(:database_name) { FFaker::Internet.user_name }
16  let(:database_host) { "localhost" }
17  let(:database_user) { FFaker::Internet.user_name }
18  let(:database_password) { "password" }
19
20  before :each do
21    stub_command('ls /var/data/recovery.conf').and_return(true)
22  end
23
24  it 'creates the specified database' do
25    expect(subject).to create_postgresql_database(database_name)
26  end
27
28  it 'creates the database user' do
29    expect(subject).to create_postgresql_database_user(database_user)
30  end
31
32  it 'grants all privileges to the database user' do
33    expect(subject).to grant_postgresql_database_user(database_user)
34      .with_privileges([:all])
35  end
36end