Sha256: a4aa3eb4edea901b030881626896edecfa2d27bfb24fa70d24298cea708b228f

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path('../test_helper', __FILE__)

module Loquor
  class PathBuilderTest < Minitest::Test
    class SimplePathRepresentation
      include PathBuilder

      def initialize
        setup_path_builder("/foobar123")
      end
    end

    class ComplexPathRepresentation
      include PathBuilder

      def initialize
        setup_path_builder("/groups/:group_id/discussions")
      end
    end

    def test_find_should_get_correct_path_with_simple_path
      id = 8
      assert_equal "/foobar123", SimplePathRepresentation.new.send(:build_path)
    end

    def test_path_part_methods_are_created
      rep = ComplexPathRepresentation.new
      assert rep.respond_to?(:for_group_id)
    end

    def test_find_should_get_correct_path_with_complex_path
      group_id = 5
      rep = ComplexPathRepresentation.new
      rep.for_group_id(5)
      assert_equal "/groups/#{group_id}/discussions", rep.send(:build_path)
    end

    def test_find_should_get_raise_exception_without_path_parts
      rep = ComplexPathRepresentation.new
      assert_raises(Loquor::MissingUrlComponentError) do
        rep.send :build_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loquor-0.0.1 test/path_builder_test.rb