Chefspec and user creation


Hi there,

I’m using a before block in my spec to stub the result of a data_bag call
in my cookbook.
What I don’t get, is what I’m supposed to write in my « it » block to make
sure that I wrote the code to create as many users as there are in the data

In my recipe I will obviously do something like this (from chefspec github
page) :

data_bag(‘users’).each do |user|
data_bag_item(‘users’, user[‘id’])

In my spec I have

before do

With an entry that corresponds to the user I added to my databag.

But next ? Is the following sufficient :

it ‘performs the action’ do
expect(chef_run).to create_user(‘my-user’).with()

Where I’m supposed to repeat the object given as a parameter in the stub
call ?
Or am I supposed to call the data_bag method in the it block witch will
fetch the data stubbed rather
than real data ?

Thanks in advance

Léonard Messier