Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rspec tests for CRLF line endings fail #587

Closed
ragnarkon opened this issue Oct 31, 2018 · 1 comment
Closed

Rspec tests for CRLF line endings fail #587

ragnarkon opened this issue Oct 31, 2018 · 1 comment
Assignees

Comments

@ragnarkon
Copy link

ragnarkon commented Oct 31, 2018

Describe the bug
Unit tests that involve checking CRLF line endings fail when \r\n is used. Yet... using pry to inspect suggests the tests should pass.

case facts[:kernel]
when 'windows'
  is_expected.to contain_file('C:/example/conf/dir/conf.yaml').with(
    ensure: 'file',
    # content: "# This file is managed by Puppet\r\n---\r\nname: value\r\n",
    content: %r{---\r\n},
  )
failed: rspec: ./spec/classes/lineendings_spec.rb:9: expected that the catalogue would contain File[C:/example/conf/dir/conf.yaml] with content set to /---\r\n/ but it is set to "# This file is managed by Puppet\r\n---\r\nname: value\r\n"
expect(catalogue.resource('File[C:/example/conf/dir/conf.yaml]')[:content]).to match(%r{---\r\n})
=> true

These tests are being ran against the content parameter on file resources.

To Reproduce
While attempting to track down the issue, I creating a test module that was used to reliably reproduce the issue on several machines:
https://github.com/ragnarkon/puppet-lineendings

Expected behavior
Unit tests should pass correctly.

Additional context

Test fail reliably on the following machines:

  • macOS 10.13, PDK 1.7.1 native pkg
  • macOS 10.14, PDK 1.7.1 native pkg
  • Windows 10, PDK 1.7.1 native pkg
@rodjek rodjek self-assigned this Mar 19, 2019
@rodjek
Copy link
Contributor

rodjek commented Mar 19, 2019

Hi @ragnarkon, this error was in the version of rspec-puppet bundled in PDK 1.7.1 (rspec-puppet 2.7.1). rspec-puppet 2.7.2 was released to fix this issue and was included in PDK 1.8.0.

@rodjek rodjek closed this as completed Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants