Skip to content

MODULES-3699 Deprecation spec fix 2 #646

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

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions spec/acceptance/deprecation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
require 'shellwords'

describe 'deprecation function' do
before :each do
FileUtils.rm_rf '/tmp/deprecation'

if fact('operatingsystem') == 'windows'
test_file = 'C:/deprecation'
else
test_file = "/tmp/deprecation"
end

# It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this look like this instead:

add_file_manifest = <<-EOS
  deprecation('key', 'message')
  file { '#{test_file}': 
    ensure => present,
    content => 'test', 
  }
EOS

It's just easier to read and maintain.

Same with remove_file_manifest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be totally easier to read and maintain that way, but since it's run on the command line (puppet apply -e style) instead of with apply_manifest, Windows seems to need it formatted this way.

remove_file_manifest = "file { '#{test_file}': ensure => absent }"

before :all do
apply_manifest(remove_file_manifest)
end

context 'with --strict=error', if: get_puppet_version =~ /^4/ do
before :all do
pp = <<-EOS
deprecation('key', 'message')
file { '/tmp/deprecation': ensure => present }
EOS
@result = on(default, puppet('apply', '--strict=error', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
@result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
end

after :all do
apply_manifest(remove_file_manifest)
end

it "should return an error" do
Expand All @@ -24,18 +34,18 @@
expect(@result.stderr).to match(/deprecation. key. message/)
end

describe file('/tmp/deprecation') do
it { is_expected.not_to exist }
describe file("#{test_file}") do
it { is_expected.not_to be_file }
end
end

context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
before :all do
pp = <<-EOS
deprecation('key', 'message')
file { '/tmp/deprecation': ensure => present }
EOS
@result = on(default, puppet('apply', '--strict=warning', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
@result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
end

after :all do
apply_manifest(remove_file_manifest)
end

it "should not return an error" do
Expand All @@ -46,18 +56,18 @@
expect(@result.stderr).to match(/Warning: message/)
end

describe file('/tmp/deprecation') do
it { is_expected.to exist }
describe file("#{test_file}") do
it { is_expected.to be_file }
end
end

context 'with --strict=off', if: get_puppet_version =~ /^4/ do
before :all do
pp = <<-EOS
deprecation('key', 'message')
file { '/tmp/deprecation': ensure => present }
EOS
@result = on(default, puppet('apply', '--strict=off', '-e', Shellwords.shellescape(pp)), acceptable_exit_codes: (0...256))
@result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
end

after :all do
apply_manifest(remove_file_manifest)
end

it "should not return an error" do
Expand All @@ -68,8 +78,8 @@
expect(@result.stderr).not_to match(/Warning: message/)
end

describe file('/tmp/deprecation') do
it { is_expected.to exist }
describe file("#{test_file}") do
it { is_expected.to be_file }
end
end
end