Sha256: 4a749f51db41178beb53eb58440dae2833ec9a4d0227ddc83d36ad199a1b10af

Contents?: true

Size: 709 Bytes

Versions: 10

Compression:

Stored size: 709 Bytes

Contents

require File.join(File.dirname(__FILE__), "test_helper")

class TestString < Test::Unit::TestCase
  context "String#lines" do
    should "return the parts when separated with \\n" do
      assert_equal ["a\n", "b\n", "c\n"], "a\nb\nc\n".lines.to_a
    end

    should "return the parts when separated with \\r\\n" do
      assert_equal ["a\r\n", "b\r\n", "c\r\n"], "a\r\nb\r\nc\r\n".lines.to_a
    end

    should "accept a record separator" do
      assert_equal ["ax", "bx", "cx"], "axbxcx".lines("x").to_a
    end

    should "execute the passed block" do
      lines = ["a\r\n", "b\r\n", "c\r\n"]

      "a\r\nb\r\nc\r\n".lines do |line|
        assert_equal lines.shift, line
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ohm-0.0.38 test/1.8.6_test.rb
ohm-0.0.37 test/1.8.6_test.rb
ohm-0.0.36 test/1.8.6_test.rb
ohm-0.1.0.rc2 test/1.8.6_test.rb
ohm-0.1.0.rc1 test/1.8.6_test.rb
ohm-0.0.35 test/1.8.6_test.rb
ohm-0.0.34 test/1.8.6_test.rb
ohm-0.0.33 test/1.8.6_test.rb
ohm-0.0.32 test/1.8.6_test.rb
ohm-0.0.31 test/1.8.6_test.rb