Using node.policy_group


I am using the following code in my recipe to include a particular recipe based on policy group:
if node.policy_group.include? “policygrpA”
include_recipe ‘cookbookA::recipeA’

When I run the cookbook on end node, it reads the code fine and executes based on the policy group. An observation, if a node does not have a policy name/group associated it fails.
Additionally, I am trying to run the above using kitchen test in a docker container and I get the below error:

   Running handlers:
   [2018-05-15T06:58:26+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2018-05-15T06:58:26+00:00] ERROR: Exception handlers complete
   Chef Client failed. 0 resources updated in 03 seconds
   [2018-05-15T06:58:26+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2018-05-15T06:58:26+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2018-05-15T06:58:26+00:00] ERROR: **undefined method `include?' for nil:NilClass**
   [2018-05-15T06:58:26+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Can you please help what am I doing wrong here or does the code expect a policy name and group for the container/node.