Sha256: a1f0f982954a1f81128fb5ee31c58faa912f2b47059024b936a9df542d2e85b8

Contents?: true

Size: 509 Bytes

Versions: 4

Compression:

Stored size: 509 Bytes

Contents

require "helper"

class OhmSlugTest < Test::Unit::TestCase
  module Finder
    def [](id)
      new(id)
    end
  end

  class BaseWithoutToParam < Struct.new(:id)
    extend Finder

    include Ohm::Slug

    def to_s
      "A very Unique and Interesting String?'"
    end
  end

  test "to_param" do
    obj = BaseWithoutToParam.new(1)

    assert_equal '1-a-very-unique-and-interesting-string', obj.to_param
  end

  test "finding" do
    assert_equal 1, BaseWithoutToParam['1-a-very-unique'].id
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ohm-contrib-0.0.31 test/test_ohm_slug.rb
ohm-contrib-0.0.30 test/test_ohm_slug.rb
ohm-contrib-0.0.29 test/test_ohm_slug.rb
ohm-contrib-0.0.28 test/test_ohm_slug.rb