This confused me as well, then I realized the new string to match has brackets which need to be escaped since it's a regex. So change this line to:
`it { expect { should contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, /Cannot create a location rspec-test\(rspec-test\) of vhost vhost1 without a www_root, location_cfg_prepend, location_cfg_append, try_files, autoindex, auth_basic, auth_basic_user_file, proxy, location_alias, fastcgi, stub_status, or location_custom_cfg defined/) }`