Skip to content
This repository
tree: ef774dca65
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 57 lines (49 sloc) 2.878 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
require "minitest/autorun"
require "rails"

require "minitest/rails/action_dispatch"

class TestActionDispatchSpecType < MiniTest::Unit::TestCase
  def assert_dispatch actual
    assert_equal MiniTest::Rails::ActionDispatch::IntegrationTest, actual
  end

  def refute_dispatch actual
    refute_equal MiniTest::Rails::ActionDispatch::IntegrationTest, actual
  end

  def test_spec_type_resolves_for_matching_acceptance_strings
    assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptanceTest")
    assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance Test")
    assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptance")
    assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance")
    # And is not case sensitive
    assert_dispatch MiniTest::Spec.spec_type("widgetacceptancetest")
    assert_dispatch MiniTest::Spec.spec_type("widget acceptance test")
    assert_dispatch MiniTest::Spec.spec_type("widgetacceptance")
    assert_dispatch MiniTest::Spec.spec_type("widget acceptance")
  end

  def test_spec_type_wont_match_non_space_characters_acceptance
    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\tTest")
    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\rTest")
    # TODO: Update regex so that new lines don't match.
    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\nTest")
    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\fTest")
    refute_dispatch MiniTest::Spec.spec_type("Widget AcceptanceXTest")
  end

  def test_spec_type_resolves_for_matching_integration_strings
    assert_dispatch MiniTest::Spec.spec_type("WidgetIntegrationTest")
    assert_dispatch MiniTest::Spec.spec_type("Widget Integration Test")
    assert_dispatch MiniTest::Spec.spec_type("WidgetIntegration")
    assert_dispatch MiniTest::Spec.spec_type("Widget Integration")
    # And is not case sensitive
    assert_dispatch MiniTest::Spec.spec_type("widgetintegrationtest")
    assert_dispatch MiniTest::Spec.spec_type("widget integration test")
    assert_dispatch MiniTest::Spec.spec_type("widgetintegration")
    assert_dispatch MiniTest::Spec.spec_type("widget integration")
  end

  def test_spec_type_wont_match_non_space_characters_integration
    refute_equal MiniTest::Spec.spec_type("Widget Integration\tTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
    refute_equal MiniTest::Spec.spec_type("Widget Integration\rTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
    # TODO: Update regex so that new lines don't match.
    refute_equal MiniTest::Spec.spec_type("Widget Integration\nTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
    refute_equal MiniTest::Spec.spec_type("Widget Integration\fTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
    refute_equal MiniTest::Spec.spec_type("Widget IntegrationXTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
  end
end
Something went wrong with that request. Please try again.