minitest-rails 0.2 → 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/.travis.yml +4 -4
  2. data/CHANGELOG.rdoc +11 -0
  3. data/LICENSE +1 -1
  4. data/Manifest.txt +16 -13
  5. data/README.rdoc +11 -29
  6. data/Rakefile +6 -4
  7. data/gemfiles/3.0.gemfile +1 -2
  8. data/gemfiles/3.0.gemfile.lock +37 -38
  9. data/gemfiles/3.1.gemfile +1 -2
  10. data/gemfiles/3.1.gemfile.lock +40 -41
  11. data/gemfiles/3.2.gemfile +1 -2
  12. data/gemfiles/3.2.gemfile.lock +45 -45
  13. data/gemfiles/4.0.gemfile +8 -0
  14. data/gemfiles/4.0.gemfile.lock +104 -0
  15. data/lib/autotest/minitest_rails.rb +2 -1
  16. data/lib/generators/mini_test/controller/templates/controller_test.rb +1 -1
  17. data/lib/generators/mini_test/helper/templates/helper_test.rb +2 -2
  18. data/lib/generators/mini_test/install/install_generator.rb +1 -1
  19. data/lib/generators/mini_test/install/templates/test/minitest_helper.rb +3 -9
  20. data/lib/generators/mini_test/integration/integration_generator.rb +2 -2
  21. data/lib/generators/mini_test/integration/templates/integration_spec.rb +2 -2
  22. data/lib/generators/mini_test/integration/templates/integration_test.rb +1 -1
  23. data/lib/generators/mini_test/mailer/templates/mailer_test.rb +1 -1
  24. data/lib/generators/mini_test/model/templates/model_test.rb +1 -1
  25. data/lib/generators/mini_test/scaffold/scaffold_generator.rb +15 -0
  26. data/lib/generators/mini_test/scaffold/templates/controller_spec.rb +6 -6
  27. data/lib/generators/mini_test/scaffold/templates/controller_test.rb +7 -7
  28. data/lib/generators/mini_test.rb +25 -12
  29. data/lib/minitest/rails/constant_lookup.rb +54 -0
  30. data/lib/minitest/rails/tasks/minitest.rake +22 -51
  31. data/lib/minitest/rails/test_case.rb +93 -0
  32. data/lib/minitest/rails/testing.rb +39 -0
  33. data/lib/minitest/rails/version.rb +5 -0
  34. data/lib/minitest/rails.rb +109 -20
  35. data/lib/minitest-rails.rb +1 -1
  36. data/minitest-rails.gemspec +16 -16
  37. data/tasks/gemfiles.rake +24 -0
  38. data/tasks/test.rake +26 -0
  39. data/test/generators/test_controller_generator.rb +10 -39
  40. data/test/generators/test_helper_generator.rb +8 -35
  41. data/test/generators/test_install_generator.rb +4 -27
  42. data/test/generators/test_mailer_generator.rb +5 -29
  43. data/test/generators/test_model_generator.rb +7 -32
  44. data/test/generators/test_scaffold_generator.rb +5 -29
  45. data/test/helper.rb +35 -0
  46. data/test/rails/action_controller/test_controllers.rb +4 -14
  47. data/test/rails/action_controller/test_spec_type.rb +3 -7
  48. data/test/rails/{test_action_dispatch_spec_type.rb → action_dispatch/test_spec_type.rb} +16 -11
  49. data/test/rails/action_mailer/test_mailers.rb +109 -0
  50. data/test/rails/{test_action_mailer_spec_type.rb → action_mailer/test_spec_type.rb} +3 -8
  51. data/test/rails/action_view/test_helpers.rb +73 -0
  52. data/test/rails/{test_action_view_spec_type.rb → action_view/test_spec_type.rb} +3 -10
  53. data/test/rails/{test_active_support_spec_type.rb → active_support/test_spec_type.rb} +2 -7
  54. data/test/rails/test_constant_lookup.rb +58 -0
  55. data/test/test_sanity.rb +1 -2
  56. metadata +54 -49
  57. data/gemfiles/minitest_tu_shim.rb +0 -4
  58. data/lib/minitest/rails/action_controller.rb +0 -61
  59. data/lib/minitest/rails/action_dispatch.rb +0 -36
  60. data/lib/minitest/rails/action_mailer.rb +0 -19
  61. data/lib/minitest/rails/action_view.rb +0 -20
  62. data/lib/minitest/rails/active_support.rb +0 -68
  63. data/lib/minitest/rails/declarative.rb +0 -27
  64. data/lib/minitest/rails/mochaing.rb +0 -11
  65. data/test/rails/action_controller/test_controller_lookup.rb +0 -49
@@ -1,46 +1,21 @@
1
- require "minitest/autorun"
2
- require "minitest-rails"
3
-
4
- require "rails"
5
- require "rails/generators"
6
-
1
+ require "helper"
7
2
  require "generators/mini_test/model/model_generator"
8
3
 
9
- require "fakefs/safe"
10
-
11
- class FakeFS::File
12
- def self.binread file
13
- File.open(file, "rb") { |f| f.read }
14
- end
15
- end
16
-
17
- class TestModelGenerator < MiniTest::Unit::TestCase
18
- def setup
19
- Rails::Generators.no_color!
20
- FakeFS.activate!
21
- FakeFS::FileSystem.clone "lib/generators"
22
- end
23
-
24
- def teardown
25
- FakeFS::FileSystem.clear
26
- FakeFS.deactivate!
27
- end
4
+ class TestModelGenerator < GeneratorTest
28
5
 
29
6
  def test_model_generator
30
- out, err = capture_io do
7
+ assert_output(/create test\/models\/user_test.rb/m) do
31
8
  MiniTest::Generators::ModelGenerator.start ["user"]
32
9
  end
33
- assert_match(/create test\/models\/user_test.rb/m, out)
34
10
  assert File.exists? "test/models/user_test.rb"
35
11
  contents = File.read "test/models/user_test.rb"
36
12
  assert_match(/class UserTest/m, contents)
37
13
  end
38
14
 
39
15
  def test_model_generator_spec
40
- out, err = capture_io do
16
+ assert_output(/create test\/models\/user_test.rb/m) do
41
17
  MiniTest::Generators::ModelGenerator.start ["user", "--spec"]
42
18
  end
43
- assert_match(/create test\/models\/user_test.rb/m, out)
44
19
  assert File.exists? "test/models/user_test.rb"
45
20
  assert File.exists? "test/fixtures/users.yml"
46
21
  contents = File.read "test/models/user_test.rb"
@@ -48,18 +23,18 @@ class TestModelGenerator < MiniTest::Unit::TestCase
48
23
  end
49
24
 
50
25
  def test_model_generator_fixture
51
- out, err = capture_io do
26
+ assert_output(/create test\/fixtures\/users.yml/m) do
52
27
  MiniTest::Generators::ModelGenerator.start ["user"]
53
28
  end
54
- assert_match(/create test\/fixtures\/users.yml/m, out)
55
29
  assert File.exists? "test/fixtures/users.yml"
56
30
  end
57
31
 
58
32
  def test_model_generator_skip_fixture
59
- out, err = capture_io do
33
+ out, _ = capture_io do
60
34
  MiniTest::Generators::ModelGenerator.start ["user", "--skip-fixture"]
61
35
  end
62
36
  refute_match(/create test\/fixtures\/users.yml/m, out)
63
37
  refute File.exists? "test/fixtures/users.yml"
64
38
  end
39
+
65
40
  end
@@ -1,48 +1,24 @@
1
- require "minitest/autorun"
2
- require "minitest-rails"
3
-
4
- require "rails"
5
- require "rails/generators"
6
-
1
+ require "helper"
7
2
  require "generators/mini_test/scaffold/scaffold_generator"
8
3
 
9
- require "fakefs/safe"
10
-
11
- class FakeFS::File
12
- def self.binread file
13
- File.open(file, "rb") { |f| f.read }
14
- end
15
- end
16
-
17
- class TestScaffoldGenerator < MiniTest::Unit::TestCase
18
- def setup
19
- Rails::Generators.no_color!
20
- FakeFS.activate!
21
- FakeFS::FileSystem.clone "lib/generators"
22
- end
23
-
24
- def teardown
25
- FakeFS::FileSystem.clear
26
- FakeFS.deactivate!
27
- end
4
+ class TestScaffoldGenerator < GeneratorTest
28
5
 
29
6
  def test_scaffold_generator
30
- out, err = capture_io do
7
+ assert_output(/create test\/controllers\/users_controller_test.rb/m) do
31
8
  MiniTest::Generators::ScaffoldGenerator.start ["user"]
32
9
  end
33
- assert_match(/create test\/controllers\/users_controller_test.rb/m, out)
34
10
  assert File.exists? "test/controllers/users_controller_test.rb"
35
11
  contents = File.read "test/controllers/users_controller_test.rb"
36
12
  assert_match(/class UsersControllerTest/m, contents)
37
13
  end
38
14
 
39
15
  def test_scaffold_generator_spec
40
- out, err = capture_io do
16
+ assert_output(/create test\/controllers\/users_controller_test.rb/m) do
41
17
  MiniTest::Generators::ScaffoldGenerator.start ["user", "--spec"]
42
18
  end
43
- assert_match(/create test\/controllers\/users_controller_test.rb/m, out)
44
19
  assert File.exists? "test/controllers/users_controller_test.rb"
45
20
  contents = File.read "test/controllers/users_controller_test.rb"
46
21
  assert_match(/describe UsersController do/m, contents)
47
22
  end
23
+
48
24
  end
data/test/helper.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "minitest/autorun"
2
+
3
+ require "rails"
4
+ require "rails/generators"
5
+
6
+ require "active_record"
7
+
8
+ require "action_controller"
9
+ require "action_controller/railtie"
10
+
11
+ require "action_mailer"
12
+
13
+ require "minitest-rails"
14
+ require "minitest/rails"
15
+
16
+ require "fakefs/safe"
17
+
18
+ class FakeFS::File
19
+ def self.binread file
20
+ File.open(file, "rb") { |f| f.read }
21
+ end
22
+ end
23
+
24
+ class GeneratorTest < MiniTest::Unit::TestCase
25
+ def setup
26
+ Rails::Generators.no_color!
27
+ FakeFS.activate!
28
+ FakeFS::FileSystem.clone "lib/generators"
29
+ end
30
+
31
+ def teardown
32
+ FakeFS::FileSystem.clear
33
+ FakeFS.deactivate!
34
+ end
35
+ end
@@ -1,19 +1,9 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "minitest/rails/action_controller"
5
- require "action_controller"
6
-
7
- # require "active_record/railtie"
8
- require "action_controller/railtie"
9
- # require "action_mailer/railtie"
10
- # require "active_resource/railtie"
11
- # require "sprockets/railtie"
12
- # require "rails/test_unit/railtie"
1
+ require "helper"
13
2
 
14
3
  class TestApp < Rails::Application
15
4
  end
16
5
  Rails.application = TestApp
6
+ Rails.configuration.secret_key_base = "abc123"
17
7
 
18
8
  class ApplicationController < ActionController::Base; end
19
9
  class ModelsController < ApplicationController; end
@@ -145,7 +135,7 @@ end
145
135
 
146
136
  # Nested Admin::WidgetsControllerTest
147
137
  module Admin
148
- class WidgetsControllerTest < MiniTest::Rails::ActionController::TestCase
138
+ class WidgetsControllerTest < ActionController::TestCase
149
139
  test "exists" do
150
140
  assert_kind_of Admin::WidgetsController, @controller
151
141
  end
@@ -168,7 +158,7 @@ module Admin
168
158
  end
169
159
  end
170
160
 
171
- class Admin::WidgetsControllerTest < MiniTest::Rails::ActionController::TestCase
161
+ class Admin::WidgetsControllerTest < ActionController::TestCase
172
162
  test "exists here too" do
173
163
  assert_kind_of Admin::WidgetsController, @controller
174
164
  end
@@ -1,19 +1,15 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "minitest/rails/action_controller"
5
- require "action_controller"
1
+ require "helper"
6
2
 
7
3
  class ApplicationController < ActionController::Base; end
8
4
  class ModelsController < ApplicationController; end
9
5
 
10
6
  class TestApplicationControllerSpecType < MiniTest::Unit::TestCase
11
7
  def assert_controller actual
12
- assert_equal MiniTest::Rails::ActionController::TestCase, actual
8
+ assert_equal ActionController::TestCase, actual
13
9
  end
14
10
 
15
11
  def refute_controller actual
16
- refute_equal MiniTest::Rails::ActionController::TestCase, actual
12
+ refute_equal ActionController::TestCase, actual
17
13
  end
18
14
 
19
15
  def test_spec_type_resolves_for_class_constants
@@ -1,23 +1,24 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "minitest/rails/action_dispatch"
1
+ require "helper"
5
2
 
6
3
  class TestActionDispatchSpecType < MiniTest::Unit::TestCase
7
4
  def assert_dispatch actual
8
- assert_equal MiniTest::Rails::ActionDispatch::IntegrationTest, actual
5
+ assert_equal ActionDispatch::IntegrationTest, actual
9
6
  end
10
7
 
11
8
  def refute_dispatch actual
12
- refute_equal MiniTest::Rails::ActionDispatch::IntegrationTest, actual
9
+ refute_equal ActionDispatch::IntegrationTest, actual
13
10
  end
14
11
 
15
12
  def test_spec_type_resolves_for_matching_acceptance_strings
16
13
  assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptanceTest")
17
14
  assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance Test")
15
+ assert_dispatch MiniTest::Spec.spec_type("WidgetAcceptance")
16
+ assert_dispatch MiniTest::Spec.spec_type("Widget Acceptance")
18
17
  # And is not case sensitive
19
18
  assert_dispatch MiniTest::Spec.spec_type("widgetacceptancetest")
20
19
  assert_dispatch MiniTest::Spec.spec_type("widget acceptance test")
20
+ assert_dispatch MiniTest::Spec.spec_type("widgetacceptance")
21
+ assert_dispatch MiniTest::Spec.spec_type("widget acceptance")
21
22
  end
22
23
 
23
24
  def test_spec_type_wont_match_non_space_characters_acceptance
@@ -32,17 +33,21 @@ class TestActionDispatchSpecType < MiniTest::Unit::TestCase
32
33
  def test_spec_type_resolves_for_matching_integration_strings
33
34
  assert_dispatch MiniTest::Spec.spec_type("WidgetIntegrationTest")
34
35
  assert_dispatch MiniTest::Spec.spec_type("Widget Integration Test")
36
+ assert_dispatch MiniTest::Spec.spec_type("WidgetIntegration")
37
+ assert_dispatch MiniTest::Spec.spec_type("Widget Integration")
35
38
  # And is not case sensitive
36
39
  assert_dispatch MiniTest::Spec.spec_type("widgetintegrationtest")
37
40
  assert_dispatch MiniTest::Spec.spec_type("widget integration test")
41
+ assert_dispatch MiniTest::Spec.spec_type("widgetintegration")
42
+ assert_dispatch MiniTest::Spec.spec_type("widget integration")
38
43
  end
39
44
 
40
45
  def test_spec_type_wont_match_non_space_characters_integration
41
- refute_equal MiniTest::Spec.spec_type("Widget Integration\tTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
42
- refute_equal MiniTest::Spec.spec_type("Widget Integration\rTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
46
+ refute_equal MiniTest::Spec.spec_type("Widget Integration\tTest"), ActionDispatch::IntegrationTest
47
+ refute_equal MiniTest::Spec.spec_type("Widget Integration\rTest"), ActionDispatch::IntegrationTest
43
48
  # TODO: Update regex so that new lines don't match.
44
- refute_equal MiniTest::Spec.spec_type("Widget Integration\nTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
45
- refute_equal MiniTest::Spec.spec_type("Widget Integration\fTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
46
- refute_equal MiniTest::Spec.spec_type("Widget IntegrationXTest"), MiniTest::Rails::ActionDispatch::IntegrationTest
49
+ refute_equal MiniTest::Spec.spec_type("Widget Integration\nTest"), ActionDispatch::IntegrationTest
50
+ refute_equal MiniTest::Spec.spec_type("Widget Integration\fTest"), ActionDispatch::IntegrationTest
51
+ refute_equal MiniTest::Spec.spec_type("Widget IntegrationXTest"), ActionDispatch::IntegrationTest
47
52
  end
48
53
  end
@@ -0,0 +1,109 @@
1
+ require "helper"
2
+
3
+ class TestTestMailer < ActionMailer::Base; end
4
+
5
+ # From Rails...
6
+ class CrazyNameMailerTest < ActionMailer::TestCase
7
+ tests TestTestMailer
8
+
9
+ def test_set_mailer_class_manual
10
+ assert_equal TestTestMailer, self.class.mailer_class
11
+ end
12
+ end
13
+
14
+ class CrazySymbolNameMailerTest < ActionMailer::TestCase
15
+ tests :test_test_mailer
16
+
17
+ def test_set_mailer_class_manual_using_symbol
18
+ assert_equal TestTestMailer, self.class.mailer_class
19
+ end
20
+ end if Rails::VERSION::STRING >= "3.2"
21
+
22
+ class CrazyStringNameMailerTest < ActionMailer::TestCase
23
+ tests 'test_test_mailer'
24
+
25
+ def test_set_mailer_class_manual_using_string
26
+ assert_equal TestTestMailer, self.class.mailer_class
27
+ end
28
+ end if Rails::VERSION::STRING >= "3.2"
29
+
30
+ # New tests...
31
+ describe TestTestMailer do
32
+ it "gets the mailer from the test name" do
33
+ assert_equal TestTestMailer, self.class.mailer_class
34
+ end
35
+ end
36
+
37
+ describe TestTestMailer, :action do
38
+ it "gets the mailer from the test name" do
39
+ assert_equal TestTestMailer, self.class.mailer_class
40
+ end
41
+ end
42
+
43
+ describe TestTestMailer do
44
+ describe "nested" do
45
+ it "gets the mailer from the test name" do
46
+ assert_equal TestTestMailer, self.class.mailer_class
47
+ end
48
+ end
49
+ end
50
+
51
+ describe TestTestMailer, :action do
52
+ describe "nested" do
53
+ it "gets the mailer from the test name" do
54
+ assert_equal TestTestMailer, self.class.mailer_class
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "TestTestMailer" do
60
+ it "gets the mailer from the test name" do
61
+ assert_equal TestTestMailer, self.class.mailer_class
62
+ end
63
+ end
64
+
65
+ describe "TestTestMailerTest" do
66
+ it "gets the mailer from the test name" do
67
+ assert_equal TestTestMailer, self.class.mailer_class
68
+ end
69
+ end
70
+
71
+ describe "AnotherCrazySymbolNameMailerTest" do
72
+ tests :test_test_mailer
73
+
74
+ it "gets the mailer after setting it with a symbol" do
75
+ assert_equal TestTestMailer, self.class.mailer_class
76
+ end
77
+ end if Rails::VERSION::STRING >= "3.2"
78
+
79
+ describe "AnotherCrazyStringNameMailerTest" do
80
+ tests 'test_test_mailer'
81
+
82
+ it "gets the mailer after setting it with a string" do
83
+ assert_equal TestTestMailer, self.class.mailer_class
84
+ end
85
+ end if Rails::VERSION::STRING >= "3.2"
86
+
87
+ describe "Another Crazy Name Mailer Test" do
88
+ tests TestTestMailer
89
+
90
+ it "gets the mailer after setting it manually" do
91
+ assert_equal TestTestMailer, self.class.mailer_class
92
+ end
93
+ end
94
+
95
+ describe "Another Crazy Symbol Name Mailer Test" do
96
+ tests :test_test_mailer
97
+
98
+ it "gets the mailer after setting it with a symbol" do
99
+ assert_equal TestTestMailer, self.class.mailer_class
100
+ end
101
+ end if Rails::VERSION::STRING >= "3.2"
102
+
103
+ describe "Another Crazy String Name Mailer Test" do
104
+ tests 'test_test_mailer'
105
+
106
+ it "gets the mailer after setting it with a string" do
107
+ assert_equal TestTestMailer, self.class.mailer_class
108
+ end
109
+ end if Rails::VERSION::STRING >= "3.2"
@@ -1,20 +1,15 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "action_mailer/test_helper"
5
- require "minitest/rails/action_mailer"
6
- require "action_mailer"
1
+ require "helper"
7
2
 
8
3
  class NotificationMailer < ActionMailer::Base; end
9
4
  class Notifications < ActionMailer::Base; end
10
5
 
11
6
  class TestActionMailerSpecType < MiniTest::Unit::TestCase
12
7
  def assert_mailer actual
13
- assert_equal MiniTest::Rails::ActionMailer::TestCase, actual
8
+ assert_equal ActionMailer::TestCase, actual
14
9
  end
15
10
 
16
11
  def refute_mailer actual
17
- refute_equal MiniTest::Rails::ActionMailer::TestCase, actual
12
+ refute_equal ActionMailer::TestCase, actual
18
13
  end
19
14
 
20
15
  def test_spec_type_resolves_for_class_constants
@@ -0,0 +1,73 @@
1
+ require "helper"
2
+
3
+ module PeopleHelper
4
+ def title(text)
5
+ content_tag(:h1, text)
6
+ end
7
+
8
+ def homepage_path
9
+ people_path
10
+ end
11
+
12
+ def homepage_url
13
+ people_url
14
+ end
15
+
16
+ def link_to_person(person)
17
+ link_to person.name, person
18
+ end
19
+ end
20
+
21
+ # From Rails...
22
+ class CrazyHelperTest < ActionView::TestCase
23
+ tests PeopleHelper
24
+
25
+ def test_helper_class_can_be_set_manually_not_just_inferred
26
+ assert_equal PeopleHelper, self.class.helper_class
27
+ end
28
+ end
29
+
30
+ class CrazySymbolHelperTest < ActionView::TestCase
31
+ tests :people
32
+
33
+ def test_set_helper_class_using_symbol
34
+ assert_equal PeopleHelper, self.class.helper_class
35
+ end
36
+ end if Rails::VERSION::STRING >= "3.2"
37
+
38
+ class CrazyStringHelperTest < ActionView::TestCase
39
+ tests 'people'
40
+
41
+ def test_set_helper_class_using_string
42
+ assert_equal PeopleHelper, self.class.helper_class
43
+ end
44
+ end if Rails::VERSION::STRING >= "3.2"
45
+
46
+ # New tests...
47
+ describe PeopleHelper do
48
+ it "resolves the right helper_class" do
49
+ assert_equal PeopleHelper, self.class.helper_class
50
+ end
51
+ end
52
+
53
+ describe PeopleHelper, :helper_class do
54
+ it "resolves the right helper_class" do
55
+ assert_equal PeopleHelper, self.class.helper_class
56
+ end
57
+ end
58
+
59
+ describe PeopleHelper do
60
+ describe "even while nested" do
61
+ it "resolves the right helper_class" do
62
+ assert_equal PeopleHelper, self.class.helper_class
63
+ end
64
+ end
65
+ end
66
+
67
+ describe PeopleHelper, :helper_class do
68
+ describe "even while nested" do
69
+ it "resolves the right helper_class" do
70
+ assert_equal PeopleHelper, self.class.helper_class
71
+ end
72
+ end
73
+ end
@@ -1,15 +1,12 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "minitest/rails/action_view"
1
+ require "helper"
5
2
 
6
3
  class TestActionViewSpecType < MiniTest::Unit::TestCase
7
4
  def assert_view actual
8
- assert_equal MiniTest::Rails::ActionView::TestCase, actual
5
+ assert_equal ActionView::TestCase, actual
9
6
  end
10
7
 
11
8
  def refute_view actual
12
- refute_equal MiniTest::Rails::ActionView::TestCase, actual
9
+ refute_equal ActionView::TestCase, actual
13
10
  end
14
11
 
15
12
  def test_spec_type_resolves_for_matching_helper_strings
@@ -23,12 +20,8 @@ class TestActionViewSpecType < MiniTest::Unit::TestCase
23
20
  end
24
21
 
25
22
  def test_spec_type_resolves_for_matching_view_strings
26
- assert_view MiniTest::Spec.spec_type("WidgetView")
27
- assert_view MiniTest::Spec.spec_type("WidgetViewTest")
28
23
  assert_view MiniTest::Spec.spec_type("Widget View Test")
29
24
  # And is not case sensitive
30
- assert_view MiniTest::Spec.spec_type("widgetview")
31
- assert_view MiniTest::Spec.spec_type("widgetviewtest")
32
25
  assert_view MiniTest::Spec.spec_type("widget view test")
33
26
  end
34
27
 
@@ -1,16 +1,11 @@
1
- require "minitest/autorun"
2
- require "rails"
3
-
4
- require "active_record"
5
- load "minitest/rails/active_support.rb" # Force reload
6
- # Not sure why we need to reload, but we do...
1
+ require "helper"
7
2
 
8
3
  class SomeRandomModel < ActiveRecord::Base; end
9
4
 
10
5
  class TestActiveSupportSpecType < MiniTest::Unit::TestCase
11
6
 
12
7
  def assert_support actual
13
- assert_equal MiniTest::Rails::ActiveSupport::TestCase, actual
8
+ assert_equal ActiveSupport::TestCase, actual
14
9
  end
15
10
 
16
11
  def assert_spec actual
@@ -0,0 +1,58 @@
1
+ require "helper"
2
+
3
+ class Foo; end
4
+ class Bar < Foo;
5
+ def index; end
6
+ def self.index; end
7
+ end
8
+ class Baz < Bar; end
9
+ module FooBar; end
10
+
11
+ class TestLookup < ActiveSupport::TestCase
12
+
13
+ def find_foo(name)
14
+ self.class.determine_constant_from_test_name(name) do |constant|
15
+ Class === constant && constant < Foo
16
+ end
17
+ end
18
+
19
+ def find_module(name)
20
+ self.class.determine_constant_from_test_name(name) do |constant|
21
+ Module === constant
22
+ end
23
+ end
24
+
25
+ def test_find_bar_from_foo
26
+ assert_equal Bar, find_foo("Bar")
27
+ assert_equal Bar, find_foo("Bar::index")
28
+ assert_equal Bar, find_foo("Bar::index::authenticated")
29
+ assert_equal Bar, find_foo("BarTest")
30
+ assert_equal Bar, find_foo("BarTest::index")
31
+ assert_equal Bar, find_foo("BarTest::index::authenticated")
32
+ end
33
+
34
+ def test_find_module
35
+ assert_equal FooBar, find_module("FooBar")
36
+ assert_equal FooBar, find_module("FooBar::index")
37
+ assert_equal FooBar, find_module("FooBar::index::authenticated")
38
+ assert_equal FooBar, find_module("FooBarTest")
39
+ assert_equal FooBar, find_module("FooBarTest::index")
40
+ assert_equal FooBar, find_module("FooBarTest::index::authenticated")
41
+ end
42
+
43
+ def test_returns_nil_when_cant_find_foo
44
+ assert_nil find_foo("DoesntExist")
45
+ assert_nil find_foo("DoesntExistTest")
46
+ assert_nil find_foo("DoesntExist::Nadda")
47
+ assert_nil find_foo("DoesntExist::Nadda::Nope")
48
+ assert_nil find_foo("DoesntExist::Nadda::Nope::NotHere")
49
+ end
50
+
51
+ def test_returns_nil_when_cant_find_module
52
+ assert_nil find_module("DoesntExist")
53
+ assert_nil find_module("DoesntExistTest")
54
+ assert_nil find_module("DoesntExist::Nadda")
55
+ assert_nil find_module("DoesntExist::Nadda::Nope")
56
+ assert_nil find_module("DoesntExist::Nadda::Nope::NotHere")
57
+ end
58
+ end
data/test/test_sanity.rb CHANGED
@@ -1,5 +1,4 @@
1
- require "minitest/autorun"
2
- require "minitest-rails"
1
+ require "helper"
3
2
 
4
3
  class TestMiniTest < MiniTest::Unit::TestCase
5
4
  def test_sanity