Skip to content

Commit 314e4bb

Browse files
Fix method assertion ensuring it will match "end" with the same indentation
Otherwise it was matching "end" lines from blocks within the method body, making tests such as the migration ones fail.
1 parent 61b528e commit 314e4bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

railties/lib/rails/generators/test_case.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ def assert_class_method(method, content, &block)
163163
# end
164164
# end
165165
def assert_instance_method(method, content)
166-
assert content =~ /def #{method}(\(.+\))?(.*?)\n\s+end/m, "Expected to have method #{method}"
167-
yield $2.strip if block_given?
166+
assert content =~ /(\s+)def #{method}(\(.+\))?(.*?)\n\1end/m, "Expected to have method #{method}"
167+
yield $3.strip if block_given?
168168
end
169169
alias :assert_method :assert_instance_method
170170

0 commit comments

Comments
 (0)