Sha256: bebe611da9025e97d22e517ae9663229e1c24b2b39f07d0fe66ca767f613021a

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

require(File.dirname(__FILE__) + "/test_helper")

module FriendlyId

  module Test

    class FriendlyIdTest < ::Test::Unit::TestCase

      test "should parse a friendly_id name and sequence" do
        assert_equal ["test", "2"], "test--2".parse_friendly_id
      end

      test "should parse a friendly_id name and a double digit sequence" do
        assert_equal ["test", "12"], "test--12".parse_friendly_id
      end

      test "should parse with a default sequence of 1" do
        assert_equal ["test", "1"], "test".parse_friendly_id
      end

      test "should be parseable with a custom separator" do
        assert_equal ["test", "2"], "test:2".parse_friendly_id(":")
      end

      test "should be parseable with a custom separator and a double digit sequence" do
        assert_equal ["test", "12"], "test:12".parse_friendly_id(":")
      end

      test "should parse when default sequence separator occurs in friendly_id name" do
        assert_equal ["test--test", "2"], "test--test--2".parse_friendly_id
      end

      test "should parse when custom sequence separator occurs in friendly_id name" do
        assert_equal ["test:test", "2"], "test:test:2".parse_friendly_id(":")
      end

      test "should parse when sequence separator and number occur in friendly_id name" do
        assert_equal ["test--2--test", "1"], "test--2--test".parse_friendly_id
      end

      test "should parse when sequence separator, number and sequence occur in friendly_id name" do
        assert_equal ["test--2--test", "2"], "test--2--test--2".parse_friendly_id
      end

      test "should parse when double digit sequence separator, number and sequence occur in friendly_id name" do
        assert_equal ["test--2--test", "12"], "test--2--test--12".parse_friendly_id
      end

      test "should parse with a separator and no sequence" do
        assert_equal ["test", "1"], "test--".parse_friendly_id
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
friendly_id-3.0.1 test/friendly_id_test.rb
friendly_id-3.0.0 test/friendly_id_test.rb
friendly_id-3.0.0.beta3 test/friendly_id_test.rb
friendly_id-3.0.0.beta2 test/friendly_id_test.rb
friendly_id-3.0.0.beta1 test/friendly_id_test.rb
friendly_id-2.3.4 test/friendly_id_test.rb