Skip to content

Commit 5b0c5da

Browse files
author
Doug Edey
committed
Remove declarative testing
1 parent 89bda47 commit 5b0c5da

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ require "custom_cops/my_cop"
106106
107107
module CustomCops
108108
class MyCopTest < RuboCop::Minitest::Test
109-
test "registers offense" do
109+
def test_registers_offense
110110
assert_offense(<<~RUBY)
111111
class FooTest < Minitest::Test
112112
def test_do_something
@@ -117,7 +117,7 @@ module CustomCops
117117
RUBY
118118
end
119119

120-
test "assert offense and correction"
120+
def test_assert_offense_and_correction
121121
assert_offense(<<~RUBY)
122122
class FooTest < Minitest::Test
123123
def test_do_something
@@ -136,7 +136,7 @@ module CustomCops
136136
RUBY
137137
end
138138

139-
test "assert offense and no corrections"
139+
def test_assert_offense_and_no_corrections
140140
assert_offense(<<~RUBY)
141141
class FooTest < Minitest::Test
142142
def test_do_something
@@ -149,7 +149,7 @@ module CustomCops
149149
assert_no_corrections
150150
end
151151

152-
test "assert no offense"
152+
def test_assert_no_offense
153153
assert_no_offenses(<<~RUBY)
154154
class FooTest < Minitest::Test
155155
def test_do_something
@@ -160,7 +160,7 @@ module CustomCops
160160
end
161161

162162
# You can set the `@cop` attribute to override the auto-detected cop and provide configuration options
163-
test "override cop configuration" do
163+
def test_override_cop_configuration
164164
cop_config = RuboCop::Config.new('Minitest/MultipleAssertions' => { 'Max' => 1 })
165165
@cop = RuboCop::Cop::Minitest::MultipleAssertions.new(cop_config)
166166

lib/rubocop/minitest/support.rb

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Minitest
2222
# @example Usage
2323
#
2424
# class AssertNilTest < RuboCop::Minitest::Test
25-
# test "fails when using assert_equal(nil, ...)" do
25+
# def test_fails_when_using_assert_equal_nil
2626
# assert_offense(<<~RUBY)
2727
# class FooTest < Minitest::Test
2828
# def test_do_something
@@ -40,7 +40,7 @@ module Minitest
4040
# @example `assert_offense` and `assert_correction`
4141
#
4242
# class AssertNilTest < RuboCop::Minitest::Test
43-
# test "autocorrects when using assert_equal(nil, ...)" do
43+
# def test_autocorrects_when_using_assert_equal
4444
# assert_offense(<<~RUBY)
4545
# class FooTest < Minitest::Test
4646
# def test_do_something
@@ -72,7 +72,7 @@ module Minitest
7272
# @example `assert_offense` and `assert_no_corrections`
7373
#
7474
# class AssertNilTest < RuboCop::Minitest::Test
75-
# test "no autocorrections"
75+
# def test_no_autocorrections
7676
# assert_offense(<<~RUBY)
7777
# class FooTest < Minitest::Test
7878
# def test_do_something
@@ -86,28 +86,6 @@ module Minitest
8686
# end
8787
# end
8888
class Test < ::Minitest::Test
89-
class << self
90-
# Helper to define a test method using a String. Under the hood, it replaces
91-
# spaces with underscores and defines the test method.
92-
#
93-
# test "verify something" do
94-
# ...
95-
# end
96-
def test(name, &block)
97-
test_name = :"test_#{name.gsub(/\s+/, '_')}"
98-
defined = method_defined?(test_name)
99-
raise "#{test_name} is already defined in #{self}" if defined
100-
101-
if block
102-
define_method(test_name, &block)
103-
else
104-
define_method(test_name) do
105-
raise("No implementation provided for #{name}")
106-
end
107-
end
108-
end
109-
end
110-
11189
private
11290

11391
def setup

0 commit comments

Comments
 (0)