Please review pull request #426: (#12268) String#each is not available in Ruby 1.9 opened by (daniel-pittman)

Description:

In earlier versions of Ruby, String#each and String#each_line were identical.
In the 1.9 series the former was dropped; this audits the code for places that
should by using each_line instead.

This includes some fixes for tests that had very specific stubs around reading
file content, where the expectation - but not the test - was broken by
changing the method we invoke.

It also fixes a stub over execpipe that had a different return type to the
actual method, but which happened to work because each was defined on both
Array and String in earlier versions.

Signed-off-by: Daniel Pittman [email protected]

  • Opened: Mon Jan 30 20:58:26 UTC 2012
  • Based on: puppetlabs:2.7.x (5f23429c7b81d0cdb7166904649a8bcd8df350ae)
  • Requested merge: daniel-pittman:bug/2.7.x/12268-1.9.3-compatibility-fix (a8a0f5fc5d626ab920c4c4178dcd3f1737605ffb)

Diff follows:

diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb
index 83b75e2..d581bbf 100644
--- a/lib/puppet/file_serving/configuration/parser.rb
+++ b/lib/puppet/file_serving/configuration/parser.rb
@@ -15,7 +15,7 @@ def parse
 
     File.open(self.file) { |f|
       mount = nil
-      f.each { |line|
+      f.each_line { |line|
         # Have the count increment at the top, in case we throw exceptions.
         @count += 1
 
diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb
index 6f6b6ff..231940d 100644
--- a/lib/puppet/indirector/file_bucket_file/file.rb
+++ b/lib/puppet/indirector/file_bucket_file/file.rb
@@ -55,7 +55,7 @@ def path_match(dir_path, files_original_path)
       paths_path = ::File.join(dir_path, 'paths')
       return false unless ::File.exists?(paths_path)
       ::File.open(paths_path) do |f|
-        f.each do |line|
+        f.each_line do |line|
           return true if line.chomp == files_original_path
         end
       end
diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb
index 1e486a2..ba6c225 100644
--- a/lib/puppet/network/authconfig.rb
+++ b/lib/puppet/network/authconfig.rb
@@ -89,7 +89,7 @@ def parse
         File.open(@file) { |f|
           right = nil
           count = 1
-          f.each { |line|
+          f.each_line { |line|
             case line
             when /^\s*#/ # skip comments
               count += 1
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 8fe3da2..5548f40 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -255,7 +255,7 @@ def readconfig(check = true)
         File.open(@configuration.file) { |f|
           mount = nil
           count = 1
-          f.each { |line|
+          f.each_line { |line|
             case line
             when /^\s*#/; next # skip comments
             when /^\s*$/; next # skip blank lines
diff --git a/lib/puppet/provider/package/aix.rb b/lib/puppet/provider/package/aix.rb
index 088099d..8032962 100644
--- a/lib/puppet/provider/package/aix.rb
+++ b/lib/puppet/provider/package/aix.rb
@@ -30,7 +30,7 @@ def self.prefetch(packages)
 
     updates = {}
     sources.each do |source|
-      execute(self.srclistcmd(source)).each do |line|
+      execute(self.srclistcmd(source)).each_line do |line|
         if line =~ /^[^#][^:]*:([^:]*):([^:]*)/
           current = {}
           current[:name]    = $1
diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb
index 878153a..3a84d0a 100755
--- a/lib/puppet/provider/package/dpkg.rb
+++ b/lib/puppet/provider/package/dpkg.rb
@@ -24,7 +24,7 @@ def self.instances
       hash = {}
 
       # now turn each returned line into a package object
-      process.each { |line|
+      process.each_line { |line|
         if hash = parse_line(line)
           packages << new(hash)
         end
diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb
index 22fe6d9..2a78191 100755
--- a/lib/puppet/provider/package/macports.rb
+++ b/lib/puppet/provider/package/macports.rb
@@ -46,7 +46,7 @@ def self.hash_from_line(line, regex, fields)
 
   def self.instances
     packages = []
-    port("-q", :installed).each do |line|
+    port("-q", :installed).each_line do |line|
       if hash = parse_installed_query_line(line)
         packages << new(hash)
       end
diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index d97d571..3fb1fd7 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -22,7 +22,7 @@ def self.instances
         hash = {}
 
         # now turn each returned line into a package object
-        process.each { |line|
+        process.each_line { |line|
           if match = regex.match(line.split[0])
             fields.zip(match.captures) { |field,value|
               hash[field] = value
@@ -78,7 +78,7 @@ def get_version
       fields = [ :name, :version, :flavor ]
       master_version = 0
 
-      process.each do |line|
+      process.each_line do |line|
         if match = regex.match(line.split[0])
           # now we return the first version, unless ensure is latest
           version = match.captures[1]
diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb
index 419c841..0b826e8 100644
--- a/lib/puppet/provider/package/pkg.rb
+++ b/lib/puppet/provider/package/pkg.rb
@@ -17,7 +17,7 @@ def self.instances
       hash = {}
 
       # now turn each returned line into a package object
-      process.each { |line|
+      process.each_line { |line|
         if hash = parse_line(line)
           packages << new(hash)
         end
diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb
index a0f39a0..ae3fd89 100755
--- a/lib/puppet/provider/package/pkgutil.rb
+++ b/lib/puppet/provider/package/pkgutil.rb
@@ -20,7 +20,7 @@ def self.healthcheck()
     correct_wgetopts = false
     [ "/opt/csw/etc/pkgutil.conf", "/etc/opt/csw/pkgutil.conf" ].each do |confpath|
       File.open(confpath) do |conf|
-        conf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ }
+        conf.each_line {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ }
       end
     end
     if ! correct_wgetopts
diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb
index 30f0e4a..cc66c02 100644
--- a/lib/puppet/provider/package/portage.rb
+++ b/lib/puppet/provider/package/portage.rb
@@ -28,7 +28,7 @@ def self.instances
       end
 
       packages = []
-      search_output.each do |search_result|
+      search_output.each_line do |search_result|
         match = result_format.match(search_result)
 
         if match
@@ -89,7 +89,7 @@ def query
       end
 
       packages = []
-      search_output.each do |search_result|
+      search_output.each_line do |search_result|
         match = result_format.match(search_result)
 
         if match
diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb
index 0e1f929..ff59b6f 100755
--- a/lib/puppet/provider/package/rpm.rb
+++ b/lib/puppet/provider/package/rpm.rb
@@ -37,7 +37,7 @@ def self.instances
     begin
       execpipe("#{command(:rpm)} -qa #{sig} --nodigest --qf '#{NEVRAFORMAT}\n'") { |process|
         # now turn each returned line into a package object
-        process.each { |line|
+        process.each_line { |line|
           hash = nevra_to_hash(line)
           packages << new(hash)
         }
diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb
index f8c3dde..49aa81e 100755
--- a/lib/puppet/provider/package/sun.rb
+++ b/lib/puppet/provider/package/sun.rb
@@ -39,7 +39,7 @@ def self.instances
     execpipe(cmd) { |process|
       # we're using the long listing, so each line is a separate
       # piece of information
-      process.each { |line|
+      process.each_line { |line|
         case line
         when /^$/
           hash[:provider] = :sun
diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb
index 6419715..50ba039 100644
--- a/lib/puppet/provider/selmodule/semodule.rb
+++ b/lib/puppet/provider/selmodule/semodule.rb
@@ -21,7 +21,7 @@ def destroy
   def exists?
     self.debug "Checking for module #{@resource[:name]}"
     execpipe("#{command(:semodule)} --list") do |out|
-      out.each do |line|
+      out.each_line do |line|
         if line =~ /#{@resource[:name]}\b/
           return :true
         end
@@ -118,7 +118,7 @@ def selmodversion_loaded
     begin
       execpipe("#{command(:semodule)} --list") do |output|
         lines = output.readlines
-        lines.each do |line|
+        lines.each_line do |line|
           line.chomp!
           bits = line.split
           if bits[0] == @resource[:name]
diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb
index 380bd59..2d8f559 100755
--- a/lib/puppet/provider/service/base.rb
+++ b/lib/puppet/provider/service/base.rb
@@ -24,7 +24,7 @@ def getpid
     regex = Regexp.new(@resource[:pattern])
     self.debug "Executing '#{ps}'"
     IO.popen(ps) { |table|
-      table.each { |line|
+      table.each_line { |line|
         if regex.match(line)
           ary = line.sub(/^\s+/, '').split(/\s+/)
           return ary[1]
diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb
index eced271..4243d38 100755
--- a/lib/puppet/provider/service/src.rb
+++ b/lib/puppet/provider/service/src.rb
@@ -30,7 +30,7 @@ def stopcmd
   end
 
   def restart
-      execute([command(:lssrc), "-Ss", @resource[:name]]).each do |line|
+      execute([command(:lssrc), "-Ss", @resource[:name]]).each_line do |line|
         args = line.split(":")
 
         next unless args[0] == @resource[:name]
@@ -62,7 +62,7 @@ def restart
   end
 
   def status
-      execute([command(:lssrc), "-s", @resource[:name]]).each do |line|
+      execute([command(:lssrc), "-s", @resource[:name]]).each_line do |line|
         args = line.split
 
         # This is the header line
diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb
index 5249a91..4551204 100755
--- a/lib/puppet/provider/service/upstart.rb
+++ b/lib/puppet/provider/service/upstart.rb
@@ -20,7 +20,7 @@
   def self.instances
     instances = []
     execpipe("#{command(:initctl)} list") { |process|
-      process.each { |line|
+      process.each_line { |line|
         # needs special handling of services such as network-interface:
         # initctl list:
         # network-interface (lo) start/running
diff --git a/lib/puppet/provider/user/aix.rb b/lib/puppet/provider/user/aix.rb
index a33ed67..ce0b8a3 100755
--- a/lib/puppet/provider/user/aix.rb
+++ b/lib/puppet/provider/user/aix.rb
@@ -148,7 +148,7 @@ def get_arguments(key, value, mapping, objectinfo)
   # Get the groupname from its id
   def self.groupname_by_id(gid)
     groupname=nil
-    execute(lsgroupscmd("ALL")).each { |entry|
+    execute(lsgroupscmd("ALL")).each_line { |entry|
       attrs = self.parse_attr_list(entry, nil)
       if attrs and attrs.include? :id and gid == attrs[:id].to_i
         groupname = entry.split(" ")[0]
@@ -229,9 +229,9 @@ def password
     user = @resource[:name]
     f = File.open("/etc/security/passwd", 'r')
     # Skip to the user
-    f.each { |l| break if l  =~ /^#{user}:\s*$/ }
+    f.each_line { |l| break if l  =~ /^#{user}:\s*$/ }
     if ! f.eof?
-      f.each { |l|
+      f.each_line { |l|
         # If there is a new user stanza, stop
         break if l  =~ /^\S*:\s*$/
         # If the password= entry is found, return it
diff --git a/spec/unit/file_serving/configuration/parser_spec.rb b/spec/unit/file_serving/configuration/parser_spec.rb
index 5ccfc50..6c9aa50 100755
--- a/spec/unit/file_serving/configuration/parser_spec.rb
+++ b/spec/unit/file_serving/configuration/parser_spec.rb
@@ -14,7 +14,8 @@ module FSConfigurationParserTesting
   def mock_file_content(content)
     # We want an array, but we actually want our carriage returns on all of it.
     lines = content.split("\n").collect { |l| l + "\n" }
-    @filehandle.stubs(:each).multiple_yields(*lines)
+    @filehandle.stubs(:each_line).multiple_yields(*lines)
+    @filehandle.expects(:each).never
   end
 end
 
@@ -24,6 +25,7 @@ def mock_file_content(content)
     FileTest.stubs(:exists?).with(@path).returns(true)
     FileTest.stubs(:readable?).with(@path).returns(true)
     @filehandle = mock 'filehandle'
+    @filehandle.expects(:each).never
     File.expects(:open).with(@path).yields(@filehandle)
     @parser = Puppet::FileServing::Configuration::Parser.new(@path)
   end
@@ -32,12 +34,12 @@ def mock_file_content(content)
     include FSConfigurationParserTesting
 
     it "should allow comments" do
-      @filehandle.expects(:each).yields("# this is a comment\n")
+      @filehandle.expects(:each_line).yields("# this is a comment\n")
       proc { @parser.parse }.should_not raise_error
     end
 
     it "should allow blank lines" do
-      @filehandle.expects(:each).yields("\n")
+      @filehandle.expects(:each_line).yields("\n")
       proc { @parser.parse }.should_not raise_error
     end
 
diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb
index ca94cc1..9b33679 100755
--- a/spec/unit/network/authconfig_spec.rb
+++ b/spec/unit/network/authconfig_spec.rb
@@ -97,13 +97,14 @@
   describe "when parsing authconfig file" do
     before :each do
       @fd = stub 'fd'
+      @fd.expects(:each).never
       File.stubs(:open).yields(@fd)
       @rights.stubs(:include?).returns(false)
       @rights.stubs(:[])
     end
 
     it "should skip comments" do
-      @fd.stubs(:each).yields('  # comment')
+      @fd.stubs(:each_line).yields('  # comment')
 
       @rights.expects(:newright).never
 
@@ -111,7 +112,7 @@
     end
 
     it "should increment line number even on commented lines" do
-      @fd.stubs(:each).multiple_yields('  # comment','[puppetca]')
+      @fd.stubs(:each_line).multiple_yields('  # comment','[puppetca]')
 
       @rights.expects(:newright).with('[puppetca]', 2, 'dummy')
 
@@ -119,7 +120,7 @@
     end
 
     it "should skip blank lines" do
-      @fd.stubs(:each).yields('  ')
+      @fd.stubs(:each_line).yields('  ')
 
       @rights.expects(:newright).never
 
@@ -127,7 +128,7 @@
     end
 
     it "should increment line number even on blank lines" do
-      @fd.stubs(:each).multiple_yields('  ','[puppetca]')
+      @fd.stubs(:each_line).multiple_yields('  ','[puppetca]')
 
       @rights.expects(:newright).with('[puppetca]', 2, 'dummy')
 
@@ -135,7 +136,7 @@
     end
 
     it "should throw an error if the current namespace right already exist" do
-      @fd.stubs(:each).yields('[puppetca]')
+      @fd.stubs(:each_line).yields('[puppetca]')
 
       @rights.stubs(:include?).with("puppetca").returns(true)
 
@@ -143,7 +144,7 @@
     end
 
     it "should not throw an error if the current path right already exist" do
-      @fd.stubs(:each).yields('path /hello')
+      @fd.stubs(:each_line).yields('path /hello')
 
       @rights.stubs(:newright).with("/hello",1, 'dummy')
       @rights.stubs(:include?).with("/hello").returns(true)
@@ -152,7 +153,7 @@
     end
 
     it "should create a new right for found namespaces" do
-      @fd.stubs(:each).yields('[puppetca]')
+      @fd.stubs(:each_line).yields('[puppetca]')
 
       @rights.expects(:newright).with("[puppetca]", 1, 'dummy')
 
@@ -160,7 +161,7 @@
     end
 
     it "should create a new right for each found namespace line" do
-      @fd.stubs(:each).multiple_yields('[puppetca]', '[fileserver]')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', '[fileserver]')
 
       @rights.expects(:newright).with("[puppetca]", 1, 'dummy')
       @rights.expects(:newright).with("[fileserver]", 2, 'dummy')
@@ -169,7 +170,7 @@
     end
 
     it "should create a new right for each found path line" do
-      @fd.stubs(:each).multiple_yields('path /certificates')
+      @fd.stubs(:each_line).multiple_yields('path /certificates')
 
       @rights.expects(:newright).with("/certificates", 1, 'dummy')
 
@@ -177,7 +178,7 @@
     end
 
     it "should create a new right for each found regex line" do
-      @fd.stubs(:each).multiple_yields('path ~ .rb$')
+      @fd.stubs(:each_line).multiple_yields('path ~ .rb$')
 
       @rights.expects(:newright).with("~ .rb$", 1, 'dummy')
 
@@ -187,7 +188,7 @@
     it "should strip whitespace around ACE" do
       acl = stub 'acl', :info
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0  ')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0  ')
       @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
 
       acl.expects(:allow).with('127.0.0.1')
@@ -199,7 +200,7 @@
     it "should allow ACE inline comments" do
       acl = stub 'acl', :info
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
       @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
 
       acl.expects(:allow).with('127.0.0.1')
@@ -210,7 +211,7 @@
     it "should create an allow ACE on each subsequent allow" do
       acl = stub 'acl', :info
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', 'allow 127.0.0.1')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'allow 127.0.0.1')
       @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
 
       acl.expects(:allow).with('127.0.0.1')
@@ -221,7 +222,7 @@
     it "should create a deny ACE on each subsequent deny" do
       acl = stub 'acl', :info
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', 'deny 127.0.0.1')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'deny 127.0.0.1')
       @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
 
       acl.expects(:deny).with('127.0.0.1')
@@ -233,7 +234,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('path /certificates', 'method search,find')
+      @fd.stubs(:each_line).multiple_yields('path /certificates', 'method search,find')
       @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
 
       acl.expects(:restrict_method).with('search')
@@ -246,7 +247,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', 'method search,find')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'method search,find')
       @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
 
       lambda { @authconfig.read }.should raise_error
@@ -256,7 +257,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('path /certificates', 'environment production,development')
+      @fd.stubs(:each_line).multiple_yields('path /certificates', 'environment production,development')
       @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
 
       acl.expects(:restrict_environment).with('production')
@@ -269,7 +270,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', 'environment env')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'environment env')
       @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
 
       lambda { @authconfig.read }.should raise_error
@@ -279,7 +280,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('path /certificates', 'auth yes')
+      @fd.stubs(:each_line).multiple_yields('path /certificates', 'auth yes')
       @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
 
       acl.expects(:restrict_authenticated).with('yes')
@@ -291,7 +292,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('path /certificates', 'authenticated yes')
+      @fd.stubs(:each_line).multiple_yields('path /certificates', 'authenticated yes')
       @rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
 
       acl.expects(:restrict_authenticated).with('yes')
@@ -303,7 +304,7 @@
       acl = stub 'acl', :info
       acl.stubs(:acl_type).returns(:regex)
 
-      @fd.stubs(:each).multiple_yields('[puppetca]', 'auth yes')
+      @fd.stubs(:each_line).multiple_yields('[puppetca]', 'auth yes')
       @rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
 
       lambda { @authconfig.read }.should raise_error
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index e641460..76ec91a 100755
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -30,7 +30,8 @@
 
     it "should create and return an instance with each parsed line from dpkg-query" do
       pipe = mock 'pipe'
-      pipe.expects(:each).yields @fakeresult
+      pipe.expects(:each).never
+      pipe.expects(:each_line).yields @fakeresult
       provider.expects(:execpipe).yields pipe
 
       asdf = mock 'pkg1'
@@ -41,7 +42,8 @@
 
     it "should warn on and ignore any lines it does not understand" do
       pipe = mock 'pipe'
-      pipe.expects(:each).yields "foobar"
+      pipe.expects(:each).never
+      pipe.expects(:each_line).yields "foobar"
       provider.expects(:execpipe).yields pipe
 
       Puppet.expects(:warning)
diff --git a/spec/unit/provider/selmodule_spec.rb b/spec/unit/provider/selmodule_spec.rb
index 6719666..2ec6fc2 100755
--- a/spec/unit/provider/selmodule_spec.rb
+++ b/spec/unit/provider/selmodule_spec.rb
@@ -19,19 +19,19 @@
   describe "exists? method" do
     it "should find a module if it is already loaded" do
       @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
-      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields ["bar\t1.2.3\n", "foo\t4.4.4\n", "bang\t1.0.0\n"]
+      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n"
       @provider.exists?.should == :true
     end
 
     it "should return nil if not loaded" do
       @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
-      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields ["bar\t1.2.3\n", "bang\t1.0.0\n"]
+      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields "bar\t1.2.3\nbang\t1.0.0\n"
       @provider.exists?.should be_nil
     end
 
     it "should return nil if no modules are loaded" do
       @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
-      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields []
+      @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields ""
       @provider.exists?.should be_nil
     end
   end

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to