I did not understand the test, so my comments about the line breaks are incorrect. Instead we should use fixtures here. Fixtures work by copying a file to the module and then reading the file and seeing that the output would match that. Here's an example

https://github.com/ghoneycutt/puppet-module-inittab/blob/master/spec/classes/init_spec.rb#L120
https://github.com/ghoneycutt/puppet-module-inittab/tree/master/spec/fixtures