Sha256: 92793025082fd1c8b403ba6ba8e90335422e10b173a569d6013014e70253279b

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

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

module Rainforest
  class PathBuilderTest < ::Test::Unit::TestCase
    class FakeClass
      def abc; return "abc-value"; end
      def self.xyz; return "xyz-value"; end
    end

    setup do
      @params = {
        :dog => "dog-value"
      }
      @obj = FakeClass.new
    end

    should 'use instance methods' do
      path = "/a/:abc/123"
      expected = "/a/abc-value/123"

      actual = PathBuilder.build(path, @obj, nil)
      assert_equal(expected, actual)
    end

    should 'use class methods' do
      path = "/a/:xyz/123"
      expected = "/a/xyz-value/123"

      actual = PathBuilder.build(path, FakeClass, nil)
      assert_equal(expected, actual)
    end

    should 'use param values' do
      path = "/a/:dog/123"
      expected = "/a/dog-value/123"

      actual = PathBuilder.build(path, nil, @params)
      assert_equal(expected, actual)
    end

    should 'use both methods and params' do
      path = "/a/:dog/:abc/123"
      expected = "/a/dog-value/abc-value/123"

      actual = PathBuilder.build(path, @obj, @params)
      assert_equal(expected, actual)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rainforest-2.1.0 test/rainforest/path_builder_test.rb
rainforest-2.0.2 test/rainforest/path_builder_test.rb
rainforest-2.0.1 test/rainforest/path_builder_test.rb
rainforest-2.0.0 test/rainforest/path_builder_test.rb