Sha256: ef195bd738fcbfe67354407ccf5e2ac18fd46f03fe714ee437f216015ea80442

Contents?: true

Size: 1014 Bytes

Versions: 26

Compression:

Stored size: 1014 Bytes

Contents

require 'spec_helper'
require 'tempfile'

describe 'Monkey Patches' do
  let(:subject) { "a b c d e f\ng h i j" }

  context 'String' do
    it "should respond to lines" do
       subject.lines.to_a.should == ["a b c d e f\n", "g h i j"]
    end
    it "should accept a block" do
      our_lines = []
      subject.lines do |line| our_lines << line end
      our_lines.should == ["a b c d e f\n", "g h i j"]
    end
  end

  context 'IO' do
    it "should respond to lines" do
      our_lines = nil
      Tempfile.open("lines") do | file |
        file.write(subject)
        file.flush
        file.rewind
        our_lines = file.lines.to_a
      end
      our_lines.should == ["a b c d e f\n", "g h i j"]
    end
    it "should accept a block" do
      our_lines = []
      file = Tempfile.new("lines")
      file.write(subject)
      file.flush
      file.rewind
      file.lines.each do |line| our_lines << line end
      file.unlink
      our_lines.should == ["a b c d e f\n", "g h i j"]
    end
  end

end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
facter-1.7.6 spec/unit/util/monkey_patches_spec.rb
facter-1.7.5 spec/unit/util/monkey_patches_spec.rb
facter-1.7.5.rc2 spec/unit/util/monkey_patches_spec.rb
facter-1.7.5.rc1 spec/unit/util/monkey_patches_spec.rb
facter-1.7.4 spec/unit/util/monkey_patches_spec.rb
facter-1.7.4.rc1 spec/unit/util/monkey_patches_spec.rb
facter-1.7.3 spec/unit/util/monkey_patches_spec.rb
facter-1.7.3.rc1 spec/unit/util/monkey_patches_spec.rb
facter-1.7.2 spec/unit/util/monkey_patches_spec.rb
facter-1.7.2.rc1 spec/unit/util/monkey_patches_spec.rb
facter-1.7.1 spec/unit/util/monkey_patches_spec.rb
facter-1.7.1.rc1 spec/unit/util/monkey_patches_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/facter-1.6.17/spec/unit/util/monkey_patches_spec.rb
facter-1.7.0 spec/unit/util/monkey_patches_spec.rb
facter-1.7.0.rc2 spec/unit/util/monkey_patches_spec.rb
facter-1.7.0.rc1 spec/unit/util/monkey_patches_spec.rb
facter-1.6.18 spec/unit/util/monkey_patches_spec.rb
facter-1.6.18.rc1 spec/unit/util/monkey_patches_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/facter-1.6.17/spec/unit/util/monkey_patches_spec.rb
facter-1.6.17 spec/unit/util/monkey_patches_spec.rb