You are able to set node attributes. If you look at the stacktrace, it's complaining about this line:
expect(chef_run).to create_directory("#{node['nginx']['dir']}")
Specifically, #{node['nginx']['dir']}
. You should use a static value here, otherwise your test is pointless. Change it to:
expect(chef_run).to create_directory('/etc/nginx')