Sha256: 771bc2d43dfe91d562eac420e44ac4723e5d32de1e293f552bc2600fdf307355

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')

class RouteDogTest < Test::Unit::TestCase
  context "Constantize controllers as it comes from routes" do
    test "simples" do
      assert_equal UsersController, RouteDog.constantize_controller_str("users")
    end

    test "with composite names" do
      assert_equal ProjectSettingsController, RouteDog.constantize_controller_str("project_settings")
    end

    test "named spaced simples" do
      assert_equal Admin::UsersController, RouteDog.constantize_controller_str("admin/users")
    end

    test "named spaced with composite names" do
      assert_equal Admin::ProjectSettingsController, RouteDog.constantize_controller_str("admin/project_settings")
    end

    test "named spaced deeply" do
      assert_equal Admin::Blogs::PostsController, RouteDog.constantize_controller_str("admin/blogs/posts")
    end
  end

  context "Identify tested routes" do

    def write_tested_routes_yaml(hash)
      File.open(RouteDog.watched_routes_file, "w+") {|file| file.puts(hash.to_yaml) }
    end

    test "identify routes that respond to get method" do
      write_tested_routes_yaml("products" => {"index" => ["get"]})
      assert_equal true, RouteDog.route_tested_with_requirements?(:products, :index, :get)
    end

    test "identify routes that respond to any method" do
      write_tested_routes_yaml("products" => {"index" => ["get"]})
      assert_equal true, RouteDog.route_tested_with_requirements?(:products, :index, nil)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
route_dog-2.5.1 test/unit/route_dog_test.rb
route_dog-2.5.0 test/unit/route_dog_test.rb