minitest-spec-rails 5.4.0 → 5.5.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -0
- data/.travis.yml +8 -5
- data/Appraisals +9 -2
- data/CHANGELOG.md +5 -1
- data/Gemfile +0 -1
- data/README.md +17 -28
- data/Rakefile +4 -5
- data/gemfiles/rails41.gemfile.lock +44 -45
- data/gemfiles/rails42.gemfile.lock +64 -67
- data/gemfiles/rails50.gemfile +2 -1
- data/gemfiles/rails50.gemfile.lock +75 -80
- data/gemfiles/rails51.gemfile +8 -0
- data/gemfiles/rails51.gemfile.lock +128 -0
- data/lib/minitest-spec-rails/dsl.rb +5 -9
- data/lib/minitest-spec-rails/init/action_controller.rb +3 -7
- data/lib/minitest-spec-rails/init/action_dispatch.rb +1 -3
- data/lib/minitest-spec-rails/init/action_mailer.rb +2 -7
- data/lib/minitest-spec-rails/init/action_view.rb +1 -5
- data/lib/minitest-spec-rails/init/active_job.rb +3 -8
- data/lib/minitest-spec-rails/init/active_support.rb +8 -10
- data/lib/minitest-spec-rails/init/mini_shoulda.rb +2 -6
- data/lib/minitest-spec-rails/railtie.rb +21 -21
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/minitest-spec-rails.gemspec +5 -5
- data/test/cases/action_controller_test.rb +7 -10
- data/test/cases/action_dispatch_test.rb +10 -13
- data/test/cases/action_mailer_test.rb +7 -10
- data/test/cases/action_view_test.rb +13 -16
- data/test/cases/active_job_test.rb +38 -36
- data/test/cases/active_support_test.rb +22 -12
- data/test/cases/mini_shoulda_test.rb +0 -4
- data/test/dummy_app/app/controllers/application_controller.rb +1 -3
- data/test/dummy_app/app/controllers/users_controller.rb +1 -3
- data/test/dummy_app/app/helpers/application_helper.rb +0 -1
- data/test/dummy_app/app/helpers/foos_helper.rb +3 -1
- data/test/dummy_app/app/helpers/users_helper.rb +1 -3
- data/test/dummy_app/app/mailers/user_mailer.rb +2 -4
- data/test/dummy_app/app/models/post.rb +0 -3
- data/test/dummy_app/app/models/user.rb +0 -3
- data/test/dummy_app/config/routes.rb +1 -1
- data/test/dummy_app/init.rb +2 -4
- data/test/dummy_tests/application_controller_test.rb +3 -9
- data/test/dummy_tests/foos_helper_test.rb +0 -3
- data/test/dummy_tests/integration_test.rb +2 -8
- data/test/dummy_tests/special_users_controller_test.rb +0 -2
- data/test/dummy_tests/user_mailer_test.rb +4 -10
- data/test/dummy_tests/user_test.rb +2 -8
- data/test/dummy_tests/users_controller_test.rb +1 -3
- data/test/dummy_tests/users_helper_test.rb +2 -8
- data/test/support/shared_test_case_behavior.rb +4 -7
- data/test/test_helper.rb +0 -3
- data/test/test_helper_dummy.rb +5 -6
- metadata +8 -4
@@ -3,14 +3,13 @@ require 'test_helper'
|
|
3
3
|
class SomeRandomModel < ActiveRecord::Base; end
|
4
4
|
|
5
5
|
class ActiveSupportTest < MiniTestSpecRails::TestCase
|
6
|
-
|
7
6
|
it 'resolves spec type for active record constants' do
|
8
7
|
assert_support MiniTest::Spec.spec_type(SomeRandomModel)
|
9
8
|
assert_support MiniTest::Spec.spec_type(User)
|
10
9
|
end
|
11
10
|
|
12
11
|
it 'wont resolve spec type for random strings' do
|
13
|
-
assert_spec MiniTest::Spec.spec_type(
|
12
|
+
assert_spec MiniTest::Spec.spec_type('Unmatched String')
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
@@ -22,32 +21,32 @@ class ActiveSupportTest < MiniTestSpecRails::TestCase
|
|
22
21
|
def assert_spec(actual)
|
23
22
|
assert_equal MiniTest::Spec, actual
|
24
23
|
end
|
25
|
-
|
26
24
|
end
|
27
25
|
|
28
26
|
class ActiveSupportCallbackTest < ActiveSupport::TestCase
|
29
|
-
|
30
27
|
setup :foo
|
31
28
|
setup :bar
|
32
|
-
|
29
|
+
|
33
30
|
it 'works' do
|
34
31
|
@foo.must_equal 'foo'
|
35
32
|
@bar.must_equal 'bar'
|
36
33
|
end
|
37
|
-
|
34
|
+
|
38
35
|
private
|
39
|
-
|
40
|
-
def foo
|
41
|
-
|
42
|
-
|
36
|
+
|
37
|
+
def foo
|
38
|
+
@foo = 'foo'
|
39
|
+
end
|
40
|
+
|
41
|
+
def bar
|
42
|
+
@bar = 'bar'
|
43
|
+
end
|
43
44
|
end
|
44
45
|
|
45
46
|
class ActiveSupportSpecTest < ActiveSupport::TestCase
|
46
|
-
|
47
47
|
it 'current spec name' do
|
48
48
|
Thread.current[:current_spec].must_equal self
|
49
49
|
end
|
50
|
-
|
51
50
|
end
|
52
51
|
|
53
52
|
class ActiveSupportDescribeNamesTest < ActiveSupport::TestCase
|
@@ -66,3 +65,14 @@ class ActiveSupportDescribeNamesTest < ActiveSupport::TestCase
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
68
|
+
class ActiveSupportTestSyntaxTest < ActiveSupport::TestCase
|
69
|
+
test 'records the correct test method line number' do
|
70
|
+
method_name = public_methods(false).find do |name|
|
71
|
+
name.to_s =~ /test.*records the correct test method line number/
|
72
|
+
end
|
73
|
+
method_obj = method(method_name)
|
74
|
+
|
75
|
+
assert_match %r{test\/cases\/active_support_test.rb}, method_obj.source_location[0]
|
76
|
+
assert_equal 69, method_obj.source_location[1]
|
77
|
+
end
|
78
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'test_helper_dummy'
|
2
2
|
|
3
3
|
class PostTests < ActiveSupport::TestCase
|
4
|
-
|
5
4
|
i_suck_and_my_tests_are_order_dependent!
|
6
5
|
|
7
6
|
$teardown_ran = false
|
@@ -27,11 +26,8 @@ class PostTests < ActiveSupport::TestCase
|
|
27
26
|
end
|
28
27
|
|
29
28
|
context 'level 1' do
|
30
|
-
|
31
29
|
should 'work' do
|
32
30
|
@post.must_be_instance_of Post
|
33
31
|
end
|
34
|
-
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
class UserMailer < ActionMailer::Base
|
2
|
-
|
3
|
-
default :from => 'rails@minitest.spec'
|
2
|
+
default from: 'rails@minitest.spec'
|
4
3
|
|
5
4
|
def welcome(user)
|
6
5
|
@user = user
|
7
|
-
mail :
|
6
|
+
mail to: @user.email, subject: 'Welcome', body: "Welcome to MiniTest::Spec #{@user.email}!"
|
8
7
|
end
|
9
|
-
|
10
8
|
end
|
data/test/dummy_app/init.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
ENV[
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __dir__)
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'rails/all'
|
5
5
|
Bundler.require(:default, Rails.env)
|
6
6
|
|
7
7
|
module Dummy
|
8
8
|
class Application < ::Rails::Application
|
9
|
-
|
10
9
|
# Basic Engine
|
11
10
|
config.root = File.join __FILE__, '..'
|
12
11
|
config.cache_store = :memory_store
|
@@ -31,7 +30,6 @@ module Dummy
|
|
31
30
|
|
32
31
|
# Custom
|
33
32
|
config.minitest_spec_rails.mini_shoulda = true
|
34
|
-
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
@@ -3,7 +3,6 @@ require 'test_helper_dummy'
|
|
3
3
|
module ApplicationControllerTests
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
7
6
|
before { get :index }
|
8
7
|
|
9
8
|
it 'works' do
|
@@ -12,7 +11,7 @@ module ApplicationControllerTests
|
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'allows custom assertions' do
|
15
|
-
assert_select 'h1', :
|
14
|
+
assert_select 'h1', text: 'Rendered MiniTest::Spec'
|
16
15
|
end
|
17
16
|
|
18
17
|
it 'can find the controller_class' do
|
@@ -24,7 +23,6 @@ module ApplicationControllerTests
|
|
24
23
|
end
|
25
24
|
|
26
25
|
describe 'nested 1' do
|
27
|
-
|
28
26
|
it('works') { skip }
|
29
27
|
|
30
28
|
it 'can find the controller_class' do
|
@@ -32,13 +30,9 @@ module ApplicationControllerTests
|
|
32
30
|
end
|
33
31
|
|
34
32
|
describe 'nested 2' do
|
35
|
-
|
36
33
|
it('works') { skip }
|
37
|
-
|
38
34
|
end
|
39
|
-
|
40
35
|
end
|
41
|
-
|
42
36
|
end
|
43
37
|
end
|
44
38
|
|
@@ -50,12 +44,12 @@ class ApplicationControllerTest < ActionController::TestCase
|
|
50
44
|
end
|
51
45
|
describe 'level 1' do
|
52
46
|
it 'reflects' do
|
53
|
-
described_class.must_equal
|
47
|
+
described_class.must_equal ApplicationController
|
54
48
|
self.class.described_class.must_equal ApplicationController
|
55
49
|
end
|
56
50
|
describe 'level 2' do
|
57
51
|
it 'reflects' do
|
58
|
-
described_class.must_equal
|
52
|
+
described_class.must_equal ApplicationController
|
59
53
|
self.class.described_class.must_equal ApplicationController
|
60
54
|
end
|
61
55
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'test_helper_dummy'
|
2
2
|
|
3
3
|
class FoosHelperTest < ActionView::TestCase
|
4
|
-
|
5
4
|
it 'allows path and url helpers' do
|
6
5
|
users_path_helper.must_equal '/users'
|
7
6
|
users_url_helper.must_equal 'http://test.host/users'
|
@@ -12,6 +11,4 @@ class FoosHelperTest < ActionView::TestCase
|
|
12
11
|
assert passes
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
|
-
|
@@ -3,7 +3,6 @@ require 'test_helper_dummy'
|
|
3
3
|
module IntegrationTests
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
7
6
|
fixtures :all
|
8
7
|
|
9
8
|
it 'works' do
|
@@ -12,7 +11,7 @@ module IntegrationTests
|
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'works with assert_routing' do
|
15
|
-
assert_routing '/', :
|
14
|
+
assert_routing '/', controller: 'application', action: 'index'
|
16
15
|
end
|
17
16
|
|
18
17
|
it 'can find the app' do
|
@@ -20,7 +19,6 @@ module IntegrationTests
|
|
20
19
|
end
|
21
20
|
|
22
21
|
describe 'nested 1' do
|
23
|
-
|
24
22
|
it('works') { skip }
|
25
23
|
|
26
24
|
it 'can find the app' do
|
@@ -28,13 +26,9 @@ module IntegrationTests
|
|
28
26
|
end
|
29
27
|
|
30
28
|
describe 'nested 2' do
|
31
|
-
|
32
29
|
it('works') { skip }
|
33
|
-
|
34
30
|
end
|
35
|
-
|
36
31
|
end
|
37
|
-
|
38
32
|
end
|
39
33
|
end
|
40
34
|
|
@@ -44,6 +38,6 @@ end
|
|
44
38
|
|
45
39
|
class AppTest < ActionDispatch::IntegrationTest
|
46
40
|
def test_homepage
|
47
|
-
assert_routing '/', :
|
41
|
+
assert_routing '/', controller: 'application', action: 'index'
|
48
42
|
end
|
49
43
|
end
|
@@ -3,15 +3,14 @@ require 'test_helper_dummy'
|
|
3
3
|
module UserMailerTests
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
7
6
|
let(:deliveries) { ActionMailer::Base.deliveries }
|
8
7
|
let(:user_mailer_class) { UserMailer }
|
9
|
-
let(:user_email)
|
8
|
+
let(:user_email) do
|
10
9
|
user_mailer_class.welcome(user_ken).tap do |mail|
|
11
10
|
laterable = Rails.version > '4.2' || Rails.version.starts_with?('4.2')
|
12
11
|
laterable ? mail.deliver_now : mail.deliver
|
13
12
|
end
|
14
|
-
|
13
|
+
end
|
15
14
|
|
16
15
|
it 'works' do
|
17
16
|
deliveries.must_be :empty?
|
@@ -31,7 +30,6 @@ module UserMailerTests
|
|
31
30
|
end
|
32
31
|
|
33
32
|
describe 'nested 1' do
|
34
|
-
|
35
33
|
it('works') { skip }
|
36
34
|
|
37
35
|
it 'can find the mailer_class' do
|
@@ -39,13 +37,9 @@ module UserMailerTests
|
|
39
37
|
end
|
40
38
|
|
41
39
|
describe 'nested 2' do
|
42
|
-
|
43
40
|
it('works') { skip }
|
44
|
-
|
45
41
|
end
|
46
|
-
|
47
42
|
end
|
48
|
-
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
@@ -57,12 +51,12 @@ class UserMailerTest < ActionMailer::TestCase
|
|
57
51
|
end
|
58
52
|
describe 'level 1' do
|
59
53
|
it 'reflects' do
|
60
|
-
described_class.must_equal
|
54
|
+
described_class.must_equal UserMailer
|
61
55
|
self.class.described_class.must_equal UserMailer
|
62
56
|
end
|
63
57
|
describe 'level 2' do
|
64
58
|
it 'reflects' do
|
65
|
-
described_class.must_equal
|
59
|
+
described_class.must_equal UserMailer
|
66
60
|
self.class.described_class.must_equal UserMailer
|
67
61
|
end
|
68
62
|
end
|
@@ -3,7 +3,6 @@ require 'test_helper_dummy'
|
|
3
3
|
module UserTests
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
7
6
|
it 'works' do
|
8
7
|
user_ken.must_be_instance_of User
|
9
8
|
end
|
@@ -17,21 +16,16 @@ module UserTests
|
|
17
16
|
end
|
18
17
|
|
19
18
|
describe 'nested 1' do
|
20
|
-
|
21
19
|
it('works') { skip }
|
22
20
|
|
23
21
|
describe 'nested 2' do
|
24
|
-
|
25
22
|
it('works') { skip }
|
26
|
-
|
27
23
|
end
|
28
24
|
|
29
25
|
test 'works with test' do
|
30
26
|
user_ken.must_be_instance_of User
|
31
27
|
end
|
32
|
-
|
33
28
|
end
|
34
|
-
|
35
29
|
end
|
36
30
|
end
|
37
31
|
|
@@ -43,12 +37,12 @@ class UserTest < ActiveSupport::TestCase
|
|
43
37
|
end
|
44
38
|
describe 'level 1' do
|
45
39
|
it 'reflects' do
|
46
|
-
described_class.must_equal
|
40
|
+
described_class.must_equal User
|
47
41
|
self.class.described_class.must_equal User
|
48
42
|
end
|
49
43
|
describe 'level 2' do
|
50
44
|
it 'reflects' do
|
51
|
-
described_class.must_equal
|
45
|
+
described_class.must_equal User
|
52
46
|
self.class.described_class.must_equal User
|
53
47
|
end
|
54
48
|
end
|
@@ -3,7 +3,6 @@ require 'test_helper_dummy'
|
|
3
3
|
module UsersControllerTests
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
7
6
|
it 'works' do
|
8
7
|
get :index
|
9
8
|
assert_select 'h1', "All #{User.count} Users"
|
@@ -17,9 +16,8 @@ module UsersControllerTests
|
|
17
16
|
private
|
18
17
|
|
19
18
|
def put_update_0
|
20
|
-
rails5? ? put(:update, :
|
19
|
+
rails5? ? put(:update, params: { id: 0 }) : put(:update, id: 0)
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|