]> gitweb.fluxo.info Git - puppet-mailalias_core.git/commitdiff
Fix rubocop violations
authorMelissa Stone <melissa@puppet.com>
Fri, 13 Apr 2018 22:10:47 +0000 (15:10 -0700)
committerMelissa Stone <melissa@puppet.com>
Mon, 16 Apr 2018 23:19:34 +0000 (16:19 -0700)
acceptance/tests/resource/mailalias/create.rb
acceptance/tests/resource/mailalias/destroy.rb
acceptance/tests/resource/mailalias/modify.rb
acceptance/tests/resource/mailalias/query.rb
lib/puppet/provider/mailalias/aliases.rb
lib/puppet/type/mailalias.rb
spec/integration/provider/mailalias/aliases_spec.rb [changed mode: 0644->0755]
spec/lib/puppet_spec/files.rb
spec/shared_behaviours/all_parsedfile_providers.rb
spec/spec_helper.rb
spec/unit/type/mailalias_spec.rb [changed mode: 0644->0755]

index e1d40b9cd28af5f93ef72c0e5a3925c1a7665bfd..c6a073c04a6039618cd5223b2871f767262ee6f3 100644 (file)
@@ -1,32 +1,32 @@
-test_name "should create an email alias"
+test_name 'should create an email alias'
 
-confine :except, :platform => 'windows' 
+confine :except, platform: 'windows'
 
 tag 'audit:low',
     'audit:refactor',  # Use block style `test_name`
     'audit:acceptance' # Could be done at the integration (or unit) layer though
-                       # actual changing of resources could irreparably damage a
-                       # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
 
-name = "pl#{rand(999999).to_i}"
+name = "pl#{rand(999_999).to_i}"
 agents.each do |agent|
   teardown do
-    #(teardown) restore the alias file
-    on(agent, "mv /tmp/aliases /etc/aliases", :acceptable_exit_codes => [0,1])
+    # (teardown) restore the alias file
+    on(agent, 'mv /tmp/aliases /etc/aliases', acceptable_exit_codes: [0, 1])
   end
 
   #------- SETUP -------#
-  step "(setup) backup alias file"
-  on(agent, "cp /etc/aliases /tmp/aliases", :acceptable_exit_codes => [0,1])
+  step '(setup) backup alias file'
+  on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
 
   #------- TESTS -------#
-  step "create a mailalias with puppet"
+  step 'create a mailalias with puppet'
   args = ['ensure=present',
           'recipient="foo,bar,baz"']
   on(agent, puppet_resource('mailalias', name, args))
 
-  step "verify the alias exists"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_match(/#{name}:.*foo,bar,baz/, res.stdout, "mailalias not in aliases file")
+  step 'verify the alias exists'
+  on(agent, 'cat /etc/aliases') do |res|
+    assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
   end
-end  
+end
index 63bc3d0e4d852886b373f5a2bed95040d9d1aced..530a90b3012f94b4b552c14e240d15472d709e72 100644 (file)
@@ -1,41 +1,40 @@
-test_name "should delete an email alias"
+test_name 'should delete an email alias'
 
-confine :except, :platform => 'windows'
+confine :except, platform: 'windows'
 
 tag 'audit:low',
     'audit:refactor',  # Use block style `test_name`
     'audit:acceptance' # Could be done at the integration (or unit) layer though
-                       # actual changing of resources could irreparably damage a
-                       # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
 
-name = "pl#{rand(999999).to_i}"
+name = "pl#{rand(999_999).to_i}"
 agents.each do |agent|
   teardown do
-    #(teardown) restore the alias file
-    on(agent, "mv /tmp/aliases /etc/aliases", :acceptable_exit_codes => [0,1])
+    # (teardown) restore the alias file
+    on(agent, 'mv /tmp/aliases /etc/aliases', acceptable_exit_codes: [0, 1])
   end
 
   #------- SETUP -------#
-  step "(setup) backup alias file"
-  on(agent, "cp /etc/aliases /tmp/aliases", :acceptable_exit_codes => [0,1])
+  step '(setup) backup alias file'
+  on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
 
-  step "(setup) create a mailalias"
+  step '(setup) create a mailalias'
   on(agent, "echo '#{name}: foo,bar,baz' >> /etc/aliases")
 
-  step "(setup) verify the alias exists"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_match(/#{name}:.*foo,bar,baz/, res.stdout, "mailalias not in aliases file")
+  step '(setup) verify the alias exists'
+  on(agent, 'cat /etc/aliases')  do |res|
+    assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
   end
 
   #------- TESTS -------#
-  step "delete the aliases database with puppet"
+  step 'delete the aliases database with puppet'
   args = ['ensure=absent',
           'recipient="foo,bar,baz"']
   on(agent, puppet_resource('mailalias', name, args))
 
-
-  step "verify the alias is absent"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_no_match(/#{name}:.*foo,bar,baz/, res.stdout, "mailalias was not removed from aliases file")
+  step 'verify the alias is absent'
+  on(agent, 'cat /etc/aliases') do |res|
+    assert_no_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias was not removed from aliases file')
   end
-end  
+end
index 832043b0f3defc345c313b76bd4290bbfb77bba9..7978a7e9f972de94147ce5193ddff2cd7737045b 100644 (file)
@@ -1,41 +1,40 @@
-test_name "should modify an email alias"
+test_name 'should modify an email alias'
 
-confine :except, :platform => 'windows'
+confine :except, platform: 'windows'
 
 tag 'audit:low',
     'audit:refactor',  # Use block style `test_name`
     'audit:acceptance' # Could be done at the integration (or unit) layer though
-                       # actual changing of resources could irreparably damage a
-                       # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
 
-name = "pl#{rand(999999).to_i}"
+name = "pl#{rand(999_999).to_i}"
 agents.each do |agent|
   teardown do
-    #(teardown) restore the alias file
-    on(agent, "mv /tmp/aliases /etc/aliases", :acceptable_exit_codes => [0,1])
+    # (teardown) restore the alias file
+    on(agent, 'mv /tmp/aliases /etc/aliases', acceptable_exit_codes: [0, 1])
   end
 
   #------- SETUP -------#
-  step "(setup) backup alias file"
-  on(agent, "cp /etc/aliases /tmp/aliases", :acceptable_exit_codes => [0,1])
+  step '(setup) backup alias file'
+  on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
 
-  step "(setup) create a mailalias"
+  step '(setup) create a mailalias'
   on(agent, "echo '#{name}: foo,bar,baz' >> /etc/aliases")
 
-  step "(setup) verify the alias exists"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_match(/#{name}:.*foo,bar,baz/, res.stdout, "mailalias not in aliases file")
+  step '(setup) verify the alias exists'
+  on(agent, 'cat /etc/aliases')  do |res|
+    assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
   end
 
   #------- TESTS -------#
-  step "modify the aliases database with puppet"
+  step 'modify the aliases database with puppet'
   args = ['ensure=present',
           'recipient="foo,bar,baz,blarvitz"']
   on(agent, puppet_resource('mailalias', name, args))
 
-
-  step "verify the updated alias is present"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_match(/#{name}:.*foo,bar,baz,blarvitz/, res.stdout, "updated mailalias not in aliases file")
+  step 'verify the updated alias is present'
+  on(agent, 'cat /etc/aliases')  do |res|
+    assert_match(%r{#{name}:.*foo,bar,baz,blarvitz}, res.stdout, 'updated mailalias not in aliases file')
   end
 end
index 40e495ae0723381786edbe025f1eff7b6c6d6be4..f63e4cfc45a98277c8ca6a40163e1eaa7659e0c2 100644 (file)
@@ -1,34 +1,34 @@
-test_name "should be able to find an exisitng email alias"
+test_name 'should be able to find an exisitng email alias'
 
-confine :except, :platform => 'windows'
+confine :except, platform: 'windows'
 
 tag 'audit:low',
     'audit:refactor',  # Use block style `test_name`
     'audit:acceptance' # Could be done at the integration (or unit) layer though
-                       # actual changing of resources could irreparably damage a
-                       # host running this, or require special permissions.
+# actual changing of resources could irreparably damage a
+# host running this, or require special permissions.
 
-name = "pl#{rand(999999).to_i}"
+name = "pl#{rand(999_999).to_i}"
 agents.each do |agent|
   teardown do
-    #(teardown) restore the alias file
-    on(agent, "mv /tmp/aliases /etc/aliases", :acceptable_exit_codes => [0,1])
+    # (teardown) restore the alias file
+    on(agent, 'mv /tmp/aliases /etc/aliases', acceptable_exit_codes: [0, 1])
   end
 
   #------- SETUP -------#
-  step "(setup) backup alias file"
-  on(agent, "cp /etc/aliases /tmp/aliases", :acceptable_exit_codes => [0,1])
+  step '(setup) backup alias file'
+  on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
 
-  step "(setup) create a mailalias"
+  step '(setup) create a mailalias'
   on(agent, "echo '#{name}: foo,bar,baz' >> /etc/aliases")
 
-  step "(setup) verify the alias exists"
-  on(agent, "cat /etc/aliases")  do |res|
-    assert_match(/#{name}:.*foo,bar,baz/, res.stdout, "mailalias not in aliases file")
+  step '(setup) verify the alias exists'
+  on(agent, 'cat /etc/aliases')  do |res|
+    assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
   end
 
   #------- TESTS -------#
-  step "query for the mail alias with puppet"
+  step 'query for the mail alias with puppet'
   on(agent, puppet_resource('mailalias', name)) do
     fail_test "didn't find the scheduled_task #{name}" unless stdout.include? 'present'
   end
index 038d450d6cd696a8dce4645ebd840db5eeb115a5..9a9fa22fbc263eebeb7aefb37a883940d44116d1 100644 (file)
@@ -2,49 +2,48 @@ require 'puppet/provider/parsedfile'
 
 Puppet::Type.type(:mailalias).provide(
   :aliases,
-  :parent => Puppet::Provider::ParsedFile,
-  :default_target => "/etc/aliases",
-  :filetype => :flat
+  parent: Puppet::Provider::ParsedFile,
+  default_target: '/etc/aliases',
+  filetype: :flat,
 ) do
-  text_line :comment, :match => /^#/
-  text_line :blank, :match => /^\s*$/
+  text_line :comment, match: %r{^#}
+  text_line :blank, match: %r{^\s*$}
 
-  record_line :aliases, :fields => %w{name recipient}, :separator => /\s*:\s*/, :block_eval => :instance do
+  record_line :aliases, fields: %w[name recipient], separator: %r{\s*:\s*}, block_eval: :instance do
     def post_parse(record)
       if record[:recipient]
-       record[:recipient] = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') }
+        record[:recipient] = record[:recipient].split(%r{\s*,\s*}).map { |d| d.gsub(%r{^['"]|['"]$}, '') }
       end
       record
     end
 
     def process(line)
       ret = {}
-      records = line.split(':',4)
+      records = line.split(':', 4)
       ret[:name] = records[0].strip
-      if records.length == 4 and records[2].strip == 'include'
-       ret[:file] = records[3].strip
+      if records.length == 4 && records[2].strip == 'include'
+        ret[:file] = records[3].strip
       else
-       records = line.split(':',2)
-       ret[:recipient] = records[1].strip
+        records = line.split(':', 2)
+        ret[:recipient] = records[1].strip
       end
       ret
     end
 
     def to_line(record)
       if record[:recipient]
-       dest = record[:recipient].collect do |d|
-         # Quote aliases that have non-alpha chars
-         if d =~ /[^-+\w@.]/
-           '"%s"' % d
-         else
-           d
-         end
-       end.join(",")
-       "#{record[:name]}: #{dest}"
+        dest = record[:recipient].map { |d|
+          # Quote aliases that have non-alpha chars
+          if d =~ %r{[^-+\w@.]}
+            '"%s"' % d
+          else
+            d
+          end
+        }.join(',')
+        "#{record[:name]}: #{dest}"
       elsif record[:file]
-       "#{record[:name]}: :include: #{record[:file]}"
+        "#{record[:name]}: :include: #{record[:file]}"
       end
     end
   end
 end
-
index b5df7b8a730f00650529da717b7563489ec64d41..b26cd1235e938785ba8a98603f3457aa02456b2a 100644 (file)
@@ -1,14 +1,15 @@
+# Creates an email alias in the local alias database.
 module Puppet
   Type.newtype(:mailalias) do
-    @doc = "Creates an email alias in the local alias database."
+    @doc = 'Creates an email alias in the local alias database.'
 
     ensurable
 
-    newparam(:name, :namevar => true) do
-      desc "The alias name."
+    newparam(:name, namevar: true) do
+      desc 'The alias name.'
     end
 
-    newproperty(:recipient, :array_matching => :all) do
+    newproperty(:recipient, array_matching: :all) do
       desc "Where email should be sent.  Multiple values
         should be specified as an array.  The file and the
         recipient entries are mutually exclusive."
@@ -19,9 +20,9 @@ module Puppet
         recipient entries are mutually exclusive."
 
       validate do |value|
-       unless Puppet::Util.absolute_path?(value)
-         fail Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }
-       end
+        unless Puppet::Util.absolute_path?(value)
+          raise Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }
+        end
       end
     end
 
@@ -29,17 +30,22 @@ module Puppet
       desc "The file in which to store the aliases.  Only used by
         those providers that write to disk."
 
-      defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
+      defaultto do
+        if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
           @resource.class.defaultprovider.default_target
         else
           nil
         end
-      }
+      end
     end
 
     validate do
       if self[:recipient] && self[:file]
-       self.fail _("You cannot specify both a recipient and a file")
+        # rubocop:disable Style/SignalException
+        # We need to override this cop because puppet overrides `fail`. We need
+        # to use the puppet implementation of `fail` rather than the default
+        # ruby implementation
+        fail _('You cannot specify both a recipient and a file')
       end
     end
   end
old mode 100644 (file)
new mode 100755 (executable)
index 64cef1c..29098f8
@@ -6,5 +6,5 @@ provider_class = Puppet::Type.type(:mailalias).provider(:aliases)
 
 describe provider_class do
   # #1560, in which we corrupt the format of complex mail aliases.
-  it_should_behave_like "all parsedfile providers", provider_class
+  it_behaves_like 'all parsedfile providers', provider_class
 end
index b02637e2df9248395c51b61a1ca4d49627f4fbb5..5fef530b65f669909db52aa791a87550927d2c3a 100644 (file)
@@ -5,26 +5,32 @@ require 'pathname'
 
 # A support module for testing files.
 module PuppetSpec::Files
+  @global_tempfiles = []
+
   def self.cleanup
-    $global_tempfiles ||= []
-    while path = $global_tempfiles.pop do
+    until @global_tempfiles.empty?
+      path = @global_tempfiles.pop
       begin
         Dir.unstub(:entries)
-        FileUtils.rm_rf path, :secure => true
-      rescue Errno::ENOENT
-        # nothing to do
+        FileUtils.rm_rf path, secure: true
       end
     end
   end
 
-  def make_absolute(path) PuppetSpec::Files.make_absolute(path) end
+  def make_absolute(path)
+    PuppetSpec::Files.make_absolute(path)
+  end
+
   def self.make_absolute(path)
     path = File.expand_path(path)
     path[0] = 'c' if Puppet.features.microsoft_windows?
     path
   end
 
-  def tmpfile(name, dir = nil) PuppetSpec::Files.tmpfile(name, dir) end
+  def tmpfile(name, dir = nil)
+    PuppetSpec::Files.tmpfile(name, dir)
+  end
+
   def self.tmpfile(name, dir = nil)
     # Generate a temporary file, just for the name...
     source = dir ? Tempfile.new(name, dir) : Tempfile.new(name)
@@ -36,14 +42,20 @@ module PuppetSpec::Files
     path
   end
 
-  def file_containing(name, contents) PuppetSpec::Files.file_containing(name, contents) end
+  def file_containing(name, contents)
+    PuppetSpec::Files.file_containing(name, contents)
+  end
+
   def self.file_containing(name, contents)
     file = tmpfile(name)
     File.open(file, 'wb') { |f| f.write(contents) }
     file
   end
 
-  def script_containing(name, contents) PuppetSpec::Files.script_containing(name, contents) end
+  def script_containing(name, contents)
+    PuppetSpec::Files.script_containing(name, contents)
+  end
+
   def self.script_containing(name, contents)
     file = tmpfile(name)
     if Puppet.features.microsoft_windows?
@@ -53,11 +65,14 @@ module PuppetSpec::Files
       text = contents[:posix]
     end
     File.open(file, 'wb') { |f| f.write(text) }
-    Puppet::FileSystem.chmod(0755, file)
+    Puppet::FileSystem.chmod(0o755, file)
     file
   end
 
-  def tmpdir(name) PuppetSpec::Files.tmpdir(name) end
+  def tmpdir(name)
+    PuppetSpec::Files.tmpdir(name)
+  end
+
   def self.tmpdir(name)
     dir = Puppet::FileSystem.expand_path(Dir.mktmpdir(name).encode!(Encoding::UTF_8))
 
@@ -66,20 +81,26 @@ module PuppetSpec::Files
     dir
   end
 
-  def dir_containing(name, contents_hash) PuppetSpec::Files.dir_containing(name, contents_hash) end
+  def dir_containing(name, contents_hash)
+    PuppetSpec::Files.dir_containing(name, contents_hash)
+  end
+
   def self.dir_containing(name, contents_hash)
     dir_contained_in(tmpdir(name), contents_hash)
   end
 
-  def dir_contained_in(dir, contents_hash) PuppetSpec::Files.dir_contained_in(dir, contents_hash) end
+  def dir_contained_in(dir, contents_hash)
+    PuppetSpec::Files.dir_contained_in(dir, contents_hash)
+  end
+
   def self.dir_contained_in(dir, contents_hash)
-    contents_hash.each do |k,v|
+    contents_hash.each do |k, v|
       if v.is_a?(Hash)
-        Dir.mkdir(tmp = File.join(dir,k))
+        Dir.mkdir(tmp = File.join(dir, k))
         dir_contained_in(tmp, v)
       else
         file = File.join(dir, k)
-        File.open(file, 'wb') {|f| f.write(v) }
+        File.open(file, 'wb') { |f| f.write(v) }
       end
     end
     dir
@@ -87,17 +108,16 @@ module PuppetSpec::Files
 
   def self.record_tmp(tmp)
     # ...record it for cleanup,
-    $global_tempfiles ||= []
-    $global_tempfiles << tmp
+    @global_tempfiles << tmp
   end
 
   def expect_file_mode(file, mode)
-    actual_mode = "%o" % Puppet::FileSystem.stat(file).mode
+    actual_mode = '%o' % Puppet::FileSystem.stat(file).mode
     target_mode = if Puppet.features.microsoft_windows?
-      mode
-    else
-      "10" + "%04i" % mode.to_i
-    end
+                    mode
+                  else
+                    '10' + '%04i' % mode.to_i
+                  end
     expect(actual_mode).to eq(target_mode)
   end
 end
index 9fdf54b60f4bc73acbc79fb11ffdbec63b890495..d697a14c7520443e908697d59cd453dc4739733c 100644 (file)
@@ -1,5 +1,5 @@
-shared_examples_for "all parsedfile providers" do |provider, *files|
-  if files.empty? then
+shared_examples_for 'all parsedfile providers' do |provider, *files|
+  if files.empty?
     files = my_fixtures
   end
 
@@ -9,12 +9,12 @@ shared_examples_for "all parsedfile providers" do |provider, *files|
       provider.prefetch
 
       text = provider.to_file(provider.target_records(file))
-      text.gsub!(/^# HEADER.+\n/, '')
+      text.gsub!(%r{^# HEADER.+\n}, '')
 
       oldlines = File.readlines(file)
       newlines = text.chomp.split "\n"
       oldlines.zip(newlines).each do |old, new|
-        expect(new.gsub(/\s+/, '')).to eq(old.chomp.gsub(/\s+/, ''))
+        expect(new.gsub(%r{\s+}, '')).to eq(old.chomp.gsub(%r{\s+}, ''))
       end
     end
   end
index 0747894fdf4df8f93c57e1aee008d41ad9fd8274..9885e2df6bba9edc7bb040cba9666f2b146b4340 100644 (file)
@@ -34,7 +34,7 @@ $LOAD_PATH.unshift File.join(dir, 'lib')
 
 # So everyone else doesn't have to include this base constant.
 module PuppetSpec
-  FIXTURE_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
+  FIXTURE_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures') unless defined?(FIXTURE_DIR)
 end
 
 require 'puppet_spec/files'
old mode 100644 (file)
new mode 100755 (executable)
index eb701c6..2a079ba
@@ -4,46 +4,52 @@ require 'spec_helper'
 describe Puppet::Type.type(:mailalias) do
   include PuppetSpec::Files
 
-  let :tmpfile_path do tmpfile('afile') end
-  let :target do tmpfile('mailalias') end
+  let :tmpfile_path do
+    tmpfile('afile')
+  end
+
+  let :target do
+    tmpfile('mailalias')
+  end
+
   let :recipient_resource do
-    described_class.new(:name => "luke", :recipient => "yay", :target => target)
+    described_class.new(name: 'luke', recipient: 'yay', target: target)
   end
 
   let :file_resource do
-    described_class.new(:name => "lukefile", :file => tmpfile_path, :target => target)
+    described_class.new(name: 'lukefile', file: tmpfile_path, target: target)
   end
 
-  it "should be initially absent as a recipient" do
+  it 'is initially absent as a recipient' do
     expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent)
   end
 
-  it "should be initially absent as an included file" do
+  it 'is initially absent as an included file' do
     expect(file_resource.retrieve_resource[:file]).to eq(:absent)
   end
 
-  it "should try and set the recipient when it does the sync" do
+  it 'tries and set the recipient when it does the sync' do
     expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent)
-    recipient_resource.property(:recipient).expects(:set).with(["yay"])
+    recipient_resource.property(:recipient).expects(:set).with(['yay'])
     recipient_resource.property(:recipient).sync
   end
 
-  it "should try and set the included file when it does the sync" do
+  it 'tries and set the included file when it does the sync' do
     expect(file_resource.retrieve_resource[:file]).to eq(:absent)
     file_resource.property(:file).expects(:set).with(tmpfile_path)
     file_resource.property(:file).sync
   end
 
-  it "should fail when file is not an absolute path" do
+  it 'fails when file is not an absolute path' do
     expect {
-      Puppet::Type.type(:mailalias).new(:name => 'x', :file => 'afile')
-    }.to raise_error Puppet::Error, /File paths must be fully qualified/
+      Puppet::Type.type(:mailalias).new(name: 'x', file: 'afile')
+    }.to raise_error Puppet::Error, %r{File paths must be fully qualified}
   end
 
-  it "should fail when both file and recipient are specified" do
+  it 'fails when both file and recipient are specified' do
     expect {
-      Puppet::Type.type(:mailalias).new(:name => 'x', :file => tmpfile_path,
-                                       :recipient => 'foo@example.com')
-    }.to raise_error Puppet::Error, /cannot specify both a recipient and a file/
+      Puppet::Type.type(:mailalias).new(name: 'x', file: tmpfile_path,
+                                        recipient: 'foo@example.com')
+    }.to raise_error Puppet::Error, %r{cannot specify both a recipient and a file}
   end
 end