Commit 26b32e27 authored by Jamie Tanna's avatar Jamie Tanna

Make user configurable

We want to actually be able to do something useful with this, like
having the user configurable, instead of only ever being able to create
a `jamie` user.
parent 57ded223
Pipeline #8517364 passed with stage
in 1 minute and 41 seconds
node.default['user'] = 'jamie'
......@@ -17,6 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
user 'create user jamie' do
username 'jamie'
user "create user #{node['user']}" do
username node['user']
end
......@@ -37,4 +37,22 @@ describe 'user-cookbook::default' do
.with(username: 'jamie')
end
end
context 'When the user attribute is set' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node|
node.automatic['user'] = 'test'
end
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'creates the test user' do
expect(chef_run).to create_user('create user test')
.with(username: 'test')
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment