How do I access Chef data_bags in InSpec
<p>I am writing InSpec tests for some new Chef recipes I am working on. I would like to utilise the data_bags used by the cookbooks to iterate through the data bag items. I can't figure out how to access them in my InSpec tests! The recipes are using the search, data_bag and data_bag_item methods. But these methods don't appear to be available in my InSpec test. I suspect these are Chef DSL specific methods? The source for the data_bags is under source control so I have access to the json for them on my local file system.</p>

<p>How do I access these data_bags in Chef_zero using InSpec syntax?</p>

<p>I found a couple of examples online but I don't see how the data_bags are actually loaded by chef_zero so that they can be used in the tests e.g. <a href="https://github.com/charlesjohnson/fundamentals-with-tests/blob/master/chef-repo/cookbooks/users/test/integration/default/serverspec/default_spec.rb" rel="nofollow noreferrer">https://github.com/charlesjohnson/fundamentals-with-tests/blob/master/chef-repo/cookbooks/users/test/integration/default/serverspec/default_spec.rb</a>
and
<a href="https://github.com/chef/chef/blob/master/kitchen-tests/test/integration/webapp/default_spec.rb" rel="nofollow noreferrer">https://github.com/chef/chef/blob/master/kitchen-tests/test/integration/webapp/default_spec.rb</a></p>

<p>I am using a Windows server 2012R2 box on a Vagrant test-kitchen. This is an example of an data bag items from one of the data bags:</p>

<pre><code>{
  "User": "mcummins",
  "FullName": "Martin Cummins",
  "id": "mcummins"
}
</code></pre>

<p>This particular data bag lists Windows Active Directory users added to the administrators group. </p>

<p>I have set the data_bag_path in my .kitchen.yml (I set it in suites and provisioner) but I haven't got to a point where I can see which one is correct:</p>

<pre><code>---
driver:
  name: vagrant
  customize:
   natdnshostresolver1: "on"

provisioner:
  name: chef_zero
  data_bags_path: ../../../data_bags
#  client_rb:
#    audit_mode: :audit_only

verifier:
  name: inspec

platforms:
   - name: mwrock/Windows2012R2
     transport:
      name: winrm

suites:
  - name: default
    data_bags_path: ../../../data_bags
    run_list:
      - recipe[SPMWindowsBuilder::default]
    verifier:
      inspec_tests:
        - test/integration
    attributes:
</code></pre>