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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.travis.yml +8 -5
  4. data/Appraisals +9 -2
  5. data/CHANGELOG.md +5 -1
  6. data/Gemfile +0 -1
  7. data/README.md +17 -28
  8. data/Rakefile +4 -5
  9. data/gemfiles/rails41.gemfile.lock +44 -45
  10. data/gemfiles/rails42.gemfile.lock +64 -67
  11. data/gemfiles/rails50.gemfile +2 -1
  12. data/gemfiles/rails50.gemfile.lock +75 -80
  13. data/gemfiles/rails51.gemfile +8 -0
  14. data/gemfiles/rails51.gemfile.lock +128 -0
  15. data/lib/minitest-spec-rails/dsl.rb +5 -9
  16. data/lib/minitest-spec-rails/init/action_controller.rb +3 -7
  17. data/lib/minitest-spec-rails/init/action_dispatch.rb +1 -3
  18. data/lib/minitest-spec-rails/init/action_mailer.rb +2 -7
  19. data/lib/minitest-spec-rails/init/action_view.rb +1 -5
  20. data/lib/minitest-spec-rails/init/active_job.rb +3 -8
  21. data/lib/minitest-spec-rails/init/active_support.rb +8 -10
  22. data/lib/minitest-spec-rails/init/mini_shoulda.rb +2 -6
  23. data/lib/minitest-spec-rails/railtie.rb +21 -21
  24. data/lib/minitest-spec-rails/version.rb +1 -1
  25. data/minitest-spec-rails.gemspec +5 -5
  26. data/test/cases/action_controller_test.rb +7 -10
  27. data/test/cases/action_dispatch_test.rb +10 -13
  28. data/test/cases/action_mailer_test.rb +7 -10
  29. data/test/cases/action_view_test.rb +13 -16
  30. data/test/cases/active_job_test.rb +38 -36
  31. data/test/cases/active_support_test.rb +22 -12
  32. data/test/cases/mini_shoulda_test.rb +0 -4
  33. data/test/dummy_app/app/controllers/application_controller.rb +1 -3
  34. data/test/dummy_app/app/controllers/users_controller.rb +1 -3
  35. data/test/dummy_app/app/helpers/application_helper.rb +0 -1
  36. data/test/dummy_app/app/helpers/foos_helper.rb +3 -1
  37. data/test/dummy_app/app/helpers/users_helper.rb +1 -3
  38. data/test/dummy_app/app/mailers/user_mailer.rb +2 -4
  39. data/test/dummy_app/app/models/post.rb +0 -3
  40. data/test/dummy_app/app/models/user.rb +0 -3
  41. data/test/dummy_app/config/routes.rb +1 -1
  42. data/test/dummy_app/init.rb +2 -4
  43. data/test/dummy_tests/application_controller_test.rb +3 -9
  44. data/test/dummy_tests/foos_helper_test.rb +0 -3
  45. data/test/dummy_tests/integration_test.rb +2 -8
  46. data/test/dummy_tests/special_users_controller_test.rb +0 -2
  47. data/test/dummy_tests/user_mailer_test.rb +4 -10
  48. data/test/dummy_tests/user_test.rb +2 -8
  49. data/test/dummy_tests/users_controller_test.rb +1 -3
  50. data/test/dummy_tests/users_helper_test.rb +2 -8
  51. data/test/support/shared_test_case_behavior.rb +4 -7
  52. data/test/test_helper.rb +0 -3
  53. data/test/test_helper_dummy.rb +5 -6
  54. 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("Unmatched String")
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 ; @foo = 'foo' ; end
41
- def bar ; @bar = 'bar' ; end
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,7 +1,5 @@
1
1
  class ApplicationController < ActionController::Base
2
-
3
2
  def index
4
- render :html => '<h1>Rendered MiniTest::Spec</h1>'.html_safe, :layout => false
3
+ render html: '<h1>Rendered MiniTest::Spec</h1>'.html_safe, layout: false
5
4
  end
6
-
7
5
  end
@@ -1,12 +1,10 @@
1
1
  class UsersController < ApplicationController
2
-
3
2
  def index
4
3
  @users = User.all
5
- render :layout => false
4
+ render layout: false
6
5
  end
7
6
 
8
7
  def update
9
8
  redirect_to users_url
10
9
  end
11
-
12
10
  end
@@ -1,3 +1,2 @@
1
1
  module ApplicationHelper
2
-
3
2
  end
@@ -2,10 +2,12 @@ module FoosHelper
2
2
  def passes
3
3
  true
4
4
  end
5
+
5
6
  def users_path_helper
6
7
  users_path
7
8
  end
9
+
8
10
  def users_url_helper
9
11
  users_url
10
12
  end
11
- end
13
+ end
@@ -1,9 +1,7 @@
1
1
  module UsersHelper
2
-
3
2
  def render_users_list(users)
4
3
  content_tag :ul do
5
- users.map{ |user| content_tag :li, user.email }.join.html_safe
4
+ users.map { |user| content_tag :li, user.email }.join.html_safe
6
5
  end
7
6
  end
8
-
9
7
  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 :to => @user.email, :subject => 'Welcome', :body => "Welcome to MiniTest::Spec #{@user.email}!"
6
+ mail to: @user.email, subject: 'Welcome', body: "Welcome to MiniTest::Spec #{@user.email}!"
8
7
  end
9
-
10
8
  end
@@ -1,6 +1,3 @@
1
1
  class Post < ActiveRecord::Base
2
-
3
2
  belongs_to :user
4
-
5
-
6
3
  end
@@ -1,6 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
-
3
2
  has_many :posts
4
-
5
-
6
3
  end
@@ -1,4 +1,4 @@
1
1
  Dummy::Application.routes.draw do
2
- root :to => 'application#index'
2
+ root to: 'application#index'
3
3
  resources :users
4
4
  end
@@ -1,12 +1,11 @@
1
- ENV["RAILS_ENV"] ||= "test"
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __FILE__)
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', :text => 'Rendered MiniTest::Spec'
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 ApplicationController
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 ApplicationController
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 '/', :controller => 'application', :action => 'index'
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 '/', :controller => 'application', :action => 'index'
41
+ assert_routing '/', controller: 'application', action: 'index'
48
42
  end
49
43
  end
@@ -1,12 +1,10 @@
1
1
  require 'test_helper_dummy'
2
2
 
3
3
  class SpecialUsersControllerTest < ActionController::TestCase
4
-
5
4
  tests UsersController
6
5
 
7
6
  it 'works' do
8
7
  get :index
9
8
  assert_select 'h1', "All #{User.count} Users"
10
9
  end
11
-
12
10
  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 UserMailer
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 UserMailer
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 User
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 User
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, :params => {:id => 0}) : put(:update, :id => 0)
19
+ rails5? ? put(:update, params: { id: 0 }) : put(:update, id: 0)
21
20
  end
22
-
23
21
  end
24
22
  end
25
23