Sha256: 977021ba42b07149d298ac6d2137d4aa3dd68730f0f02606e2c4706100ff396d

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

require "helper"

class ApplicationController < ActionController::Base; end
class ModelsController      < ApplicationController;  end

class TestApplicationControllerSpecType < Minitest::Test
  def assert_controller actual
    assert_equal ActionController::TestCase, actual
  end

  def refute_controller actual
    refute_equal ActionController::TestCase, actual
  end

  def test_spec_type_resolves_for_class_constants
    assert_controller Minitest::Spec.spec_type(ApplicationController)
    assert_controller Minitest::Spec.spec_type(ModelsController)
  end

  def test_spec_type_resolves_for_matching_strings
    assert_controller Minitest::Spec.spec_type("WidgetController")
    assert_controller Minitest::Spec.spec_type("WidgetControllerTest")
    assert_controller Minitest::Spec.spec_type("Widget Controller Test")
    # And is not case sensitive
    assert_controller Minitest::Spec.spec_type("widgetcontroller")
    assert_controller Minitest::Spec.spec_type("widgetcontrollertest")
    assert_controller Minitest::Spec.spec_type("widget controller test")
  end

  def test_spec_type_wont_match_non_space_characters
    refute_controller Minitest::Spec.spec_type("Widget Controller\tTest")
    refute_controller Minitest::Spec.spec_type("Widget Controller\rTest")
    refute_controller Minitest::Spec.spec_type("Widget Controller\nTest")
    refute_controller Minitest::Spec.spec_type("Widget Controller\fTest")
    refute_controller Minitest::Spec.spec_type("Widget ControllerXTest")
  end

  def test_spec_type_doesnt_resolve_random_strings
    refute_controller Minitest::Spec.spec_type("Unmatched String")
  end

  def test_spec_type_resolves_for_additional_desc_controller
    assert_controller Minitest::Spec.spec_type("Unmatched String", :controller)
    assert_controller Minitest::Spec.spec_type("Unmatched String", :controller, :other)
    assert_controller Minitest::Spec.spec_type("Unmatched String", :other, :controller)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
minitest-rails-2.2.1 test/rails/action_controller/test_spec_type.rb
minitest-rails-2.2.0 test/rails/action_controller/test_spec_type.rb
minitest-rails-2.1.1 test/rails/action_controller/test_spec_type.rb
minitest-rails-2.1.0 test/rails/action_controller/test_spec_type.rb