Skip to content
This repository

Add case sensitivity on spec type strings. #86

Closed
wants to merge 1 commit into from

2 participants

jippeholwerda blowmage
jippeholwerda

Ran into an issue where unit testing a model named NewsOverview resulted in the test being a subclass of MiniTest::Rails::ActionView::TestCase instead of MiniTest::Spec.
We propose to make the spec types case sensitive again.

blowmage
Owner

Did your tests use the constant?

describe NewsOverview do

Or do they use a string?

describe "NewsOverview" do
jippeholwerda

I tried both, with the same result.

blowmage
Owner

Okay. sigh

We need to rethink the naming convention then. I don't think just making it case sensitive will be enough.

jippeholwerda
blowmage
Owner

I made some changes to the rpec_type registration in the 0.5 release, but I totally forgot to write any tests around this specific situation. Can you check the latest release and see if describe NewsOverview do or describe "NewsOverview" do work for you now? I think they should, but I don't have any tests that prove it right now.

blowmage blowmage closed this pull request from a commit
blowmage Add tests for view spec_type [fixes #86]
Just make sure we don't match any test that ends in 'view'.
a02a7f1
blowmage blowmage closed this in a02a7f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 05, 2012
jippeholwerda Add case sensitivity on spec type strings. 7c26696
This page is out of date. Refresh to see the latest.
2  lib/minitest/rails/action_controller.rb
@@ -11,7 +11,7 @@ class TestCase < MiniTest::Rails::ActiveSupport::TestCase
11 11
         register_spec_type(self) do |desc|
12 12
           desc < ::ActionController::Base if desc.is_a?(Class)
13 13
         end
14  
-        register_spec_type(/Controller( ?Test)?\z/i, self)
  14
+        register_spec_type(/Controller( ?Test)?\z/, self)
15 15
 
16 16
         include ::ActionController::TestCase::Behavior
17 17
 
4  lib/minitest/rails/action_dispatch.rb
@@ -26,14 +26,14 @@ def self.app=(app)
26 26
         def app
27 27
           super || ::ActionDispatch::IntegrationTest.app
28 28
         end
29  
-        
  29
+
30 30
         def url_options
31 31
           reset! unless integration_session
32 32
           integration_session.url_options
33 33
         end
34 34
 
35 35
         # Register by name
36  
-        register_spec_type(/(Acceptance|Integration)( ?Test)?\z/i, self)
  36
+        register_spec_type(/(Acceptance|Integration)( ?Test)?\z/, self)
37 37
       end
38 38
     end
39 39
   end
2  lib/minitest/rails/action_mailer.rb
@@ -9,7 +9,7 @@ class TestCase < MiniTest::Rails::ActiveSupport::TestCase
9 9
         register_spec_type(self) do |desc|
10 10
           desc < ::ActionMailer::Base if desc.is_a?(Class)
11 11
         end
12  
-        register_spec_type(/Mailer( ?Test)?\z/i, self)
  12
+        register_spec_type(/Mailer( ?Test)?\z/, self)
13 13
 
14 14
         include ::ActionMailer::TestCase::Behavior
15 15
 
2  lib/minitest/rails/action_view.rb
@@ -8,7 +8,7 @@ class TestCase < MiniTest::Rails::ActiveSupport::TestCase
8 8
         TestController = ::ActionView::TestCase::TestController
9 9
 
10 10
         # Use AV::TestCase for the base class for helpers and views
11  
-        register_spec_type(/(Helper|View)( ?Test)?\z/i, self)
  11
+        register_spec_type(/(Helper|View)( ?Test)?\z/, self)
12 12
 
13 13
         include ::ActionView::TestCase::Behavior
14 14
 
10  test/rails/action_controller/test_spec_type.rb
@@ -25,10 +25,6 @@ def test_spec_type_resolves_for_matching_strings
25 25
     assert_controller MiniTest::Spec.spec_type("WidgetController")
26 26
     assert_controller MiniTest::Spec.spec_type("WidgetControllerTest")
27 27
     assert_controller MiniTest::Spec.spec_type("Widget Controller Test")
28  
-    # And is not case sensitive
29  
-    assert_controller MiniTest::Spec.spec_type("widgetcontroller")
30  
-    assert_controller MiniTest::Spec.spec_type("widgetcontrollertest")
31  
-    assert_controller MiniTest::Spec.spec_type("widget controller test")
32 28
   end
33 29
 
34 30
   def test_spec_type_wont_match_non_space_characters
@@ -38,4 +34,10 @@ def test_spec_type_wont_match_non_space_characters
38 34
     refute_controller MiniTest::Spec.spec_type("Widget Controller\fTest")
39 35
     refute_controller MiniTest::Spec.spec_type("Widget ControllerXTest")
40 36
   end
  37
+
  38
+  def test_spec_type_wont_match_non_acceptance_strings
  39
+    refute_controller MiniTest::Spec.spec_type("FinancialControllerAddress")
  40
+    refute_controller MiniTest::Spec.spec_type("FinancialControllerAddressTest")
  41
+    refute_controller MiniTest::Spec.spec_type("FinancialController Address Test")
  42
+  end
41 43
 end
27  test/rails/action_dispatch/test_spec_type.rb
@@ -17,20 +17,11 @@ def test_spec_type_resolves_for_matching_acceptance_strings
17 17
     assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance Test")
18 18
     assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptance")
19 19
     assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance")
20  
-    # And is not case sensitive
21  
-    assert_dispatch MiniTest::Spec.spec_type("widgetacceptancetest")
22  
-    assert_dispatch MiniTest::Spec.spec_type("widget acceptance test")
23  
-    assert_dispatch MiniTest::Spec.spec_type("widgetacceptance")
24  
-    assert_dispatch MiniTest::Spec.spec_type("widget acceptance")
25 20
   end
26 21
 
27 22
   def test_spec_type_wont_match_non_space_characters_acceptance
28 23
     refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\tTest")
29 24
     refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\rTest")
30  
-    # TODO: Update regex so that new lines don't match.
31  
-    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\nTest")
32  
-    refute_dispatch MiniTest::Spec.spec_type("Widget Acceptance\fTest")
33  
-    refute_dispatch MiniTest::Spec.spec_type("Widget AcceptanceXTest")
34 25
   end
35 26
 
36 27
   def test_spec_type_resolves_for_matching_integration_strings
@@ -38,11 +29,6 @@ def test_spec_type_resolves_for_matching_integration_strings
38 29
     assert_dispatch MiniTest::Spec.spec_type("Widget Integration Test")
39 30
     assert_dispatch MiniTest::Spec.spec_type("WidgetIntegration")
40 31
     assert_dispatch MiniTest::Spec.spec_type("Widget Integration")
41  
-    # And is not case sensitive
42  
-    assert_dispatch MiniTest::Spec.spec_type("widgetintegrationtest")
43  
-    assert_dispatch MiniTest::Spec.spec_type("widget integration test")
44  
-    assert_dispatch MiniTest::Spec.spec_type("widgetintegration")
45  
-    assert_dispatch MiniTest::Spec.spec_type("widget integration")
46 32
   end
47 33
 
48 34
   def test_spec_type_wont_match_non_space_characters_integration
@@ -53,4 +39,17 @@ def test_spec_type_wont_match_non_space_characters_integration
53 39
     refute_equal MiniTest::Spec.spec_type("Widget Integration\fTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
54 40
     refute_equal MiniTest::Spec.spec_type("Widget IntegrationXTest"),  MiniTest::Rails::ActionDispatch::IntegrationTest
55 41
   end
  42
+
  43
+  def test_spec_type_wont_match_non_acceptance_strings
  44
+    refute_dispatch MiniTest::Spec.spec_type("AcceptanceCriteria")
  45
+    refute_dispatch MiniTest::Spec.spec_type("AcceptanceCriteriaTest")
  46
+    refute_dispatch MiniTest::Spec.spec_type("Acceptance Criteria")
  47
+    refute_dispatch MiniTest::Spec.spec_type("Acceptance Criteria Test")
  48
+    refute_dispatch MiniTest::Spec.spec_type("IntegrationProcess")
  49
+    refute_dispatch MiniTest::Spec.spec_type("IntegrationProcessTest")
  50
+    refute_dispatch MiniTest::Spec.spec_type("Integration Process Test")
  51
+    refute_dispatch MiniTest::Spec.spec_type("IntegrationSolver")
  52
+    refute_dispatch MiniTest::Spec.spec_type("IntegrationSolverTest")
  53
+    refute_dispatch MiniTest::Spec.spec_type("Integration Solver Test")
  54
+  end
56 55
 end
11  test/rails/action_mailer/test_spec_type.rb
@@ -26,10 +26,6 @@ def test_spec_type_resolves_for_matching_strings
26 26
     assert_mailer MiniTest::Spec.spec_type("WidgetMailer")
27 27
     assert_mailer MiniTest::Spec.spec_type("WidgetMailerTest")
28 28
     assert_mailer MiniTest::Spec.spec_type("Widget Mailer Test")
29  
-    # And is not case sensitive
30  
-    assert_mailer MiniTest::Spec.spec_type("widgetmailer")
31  
-    assert_mailer MiniTest::Spec.spec_type("widgetmailertest")
32  
-    assert_mailer MiniTest::Spec.spec_type("widget mailer test")
33 29
   end
34 30
 
35 31
   def test_spec_type_wont_match_non_space_characters
@@ -39,4 +35,11 @@ def test_spec_type_wont_match_non_space_characters
39 35
     refute_mailer MiniTest::Spec.spec_type("Widget Mailer\fTest")
40 36
     refute_mailer MiniTest::Spec.spec_type("Widget MailerXTest")
41 37
   end
  38
+
  39
+  def test_spec_type_wont_match_non_mailer_strings
  40
+    refute_mailer MiniTest::Spec.spec_type("MailerrorTest")
  41
+    refute_mailer MiniTest::Spec.spec_type("MailErrorTest")
  42
+    refute_mailer MiniTest::Spec.spec_type("WidgetMailerWidgetTest")
  43
+    refute_mailer MiniTest::Spec.spec_type("Widget Mailer Widget Test")
  44
+  end
42 45
 end
18  test/rails/action_view/test_spec_type.rb
@@ -16,20 +16,12 @@ def test_spec_type_resolves_for_matching_helper_strings
16 16
     assert_view MiniTest::Spec.spec_type("WidgetHelper")
17 17
     assert_view MiniTest::Spec.spec_type("WidgetHelperTest")
18 18
     assert_view MiniTest::Spec.spec_type("Widget Helper Test")
19  
-    # And is not case sensitive
20  
-    assert_view MiniTest::Spec.spec_type("widgethelper")
21  
-    assert_view MiniTest::Spec.spec_type("widgethelpertest")
22  
-    assert_view MiniTest::Spec.spec_type("widget helper test")
23 19
   end
24 20
 
25 21
   def test_spec_type_resolves_for_matching_view_strings
26 22
     assert_view MiniTest::Spec.spec_type("WidgetView")
27 23
     assert_view MiniTest::Spec.spec_type("WidgetViewTest")
28 24
     assert_view MiniTest::Spec.spec_type("Widget View Test")
29  
-    # And is not case sensitive
30  
-    assert_view MiniTest::Spec.spec_type("widgetview")
31  
-    assert_view MiniTest::Spec.spec_type("widgetviewtest")
32  
-    assert_view MiniTest::Spec.spec_type("widget view test")
33 25
   end
34 26
 
35 27
   def test_spec_type_wont_match_non_space_characters
@@ -39,4 +31,14 @@ def test_spec_type_wont_match_non_space_characters
39 31
     refute_view MiniTest::Spec.spec_type("Widget Helper\fTest")
40 32
     refute_view MiniTest::Spec.spec_type("Widget HelperXTest")
41 33
   end
  34
+
  35
+  def test_spec_type_wont_match_non_view_strings
  36
+    refute_view MiniTest::Spec.spec_type("Overview")
  37
+    refute_view MiniTest::Spec.spec_type("OverviewTest")
  38
+    refute_view MiniTest::Spec.spec_type("Overview Test")
  39
+    refute_view MiniTest::Spec.spec_type("Viewer")
  40
+    refute_view MiniTest::Spec.spec_type("ViewerTest")
  41
+    refute_view MiniTest::Spec.spec_type("Viewer Test")
  42
+    refute_view MiniTest::Spec.spec_type("WidgetViewWidgetTest")
  43
+  end
42 44
 end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.