You need to tell chefspec to step into your resource. You can do this as follows:
require_relative '../spec_helper'
describe 'app_cookbook::postgresql' do
let(:chef_run) do
ChefSpec::Runner.new(step_into: ['my_lwrp']) do |node|
node.set[:app][:postgresql][:database_user] = 'test'
node.set[:app][:postgresql][:database_password] = 'test'
node.set[:app][:postgresql][:database_name] = 'testdb'
end.converge(described_recipe)
end
it 'installs postgresql 9.1 package' do
expect(chef_run).to run_execute('sudo apt-get install postgresql-9.1 -y --force-yes')
end
end
You can replace my_lwrp with the resource which you want to step into.
For more details, see the Testing LWRPS section in the Chefspec repo README.