test/cases/active_support_test.rb in minitest-spec-rails-5.4.0 vs test/cases/active_support_test.rb in minitest-spec-rails-5.5.0

- old
+ new

@@ -1,18 +1,17 @@ require 'test_helper' class SomeRandomModel < ActiveRecord::Base; end class ActiveSupportTest < MiniTestSpecRails::TestCase - it 'resolves spec type for active record constants' do assert_support MiniTest::Spec.spec_type(SomeRandomModel) assert_support MiniTest::Spec.spec_type(User) end it 'wont resolve spec type for random strings' do - assert_spec MiniTest::Spec.spec_type("Unmatched String") + assert_spec MiniTest::Spec.spec_type('Unmatched String') end private def assert_support(actual) @@ -20,36 +19,36 @@ end def assert_spec(actual) assert_equal MiniTest::Spec, actual end - end class ActiveSupportCallbackTest < ActiveSupport::TestCase - setup :foo setup :bar - + it 'works' do @foo.must_equal 'foo' @bar.must_equal 'bar' end - + private - - def foo ; @foo = 'foo' ; end - def bar ; @bar = 'bar' ; end - + + def foo + @foo = 'foo' + end + + def bar + @bar = 'bar' + end end class ActiveSupportSpecTest < ActiveSupport::TestCase - it 'current spec name' do Thread.current[:current_spec].must_equal self end - end class ActiveSupportDescribeNamesTest < ActiveSupport::TestCase it 'class name' do assert_equal 'ActiveSupportDescribeNamesTest', self.class.name @@ -64,5 +63,16 @@ end end end end +class ActiveSupportTestSyntaxTest < ActiveSupport::TestCase + test 'records the correct test method line number' do + method_name = public_methods(false).find do |name| + name.to_s =~ /test.*records the correct test method line number/ + end + method_obj = method(method_name) + + assert_match %r{test\/cases\/active_support_test.rb}, method_obj.source_location[0] + assert_equal 69, method_obj.source_location[1] + end +end