Extract method declaration regexp into a constant

This commit is contained in:
Pablo Herrero 2013-04-12 15:40:30 -03:00
parent 492e6b57d4
commit 83d0232304

@ -2,6 +2,8 @@ module Rails
module Generators
module Testing
module Assertions
METHOD_DECLARATION_REGEXP = /(\s+)def #{method}(\(.+\))?(.*?)\n\1end/m
# Asserts a given file exists. You need to supply an absolute path or a path relative
# to the configured destination:
#
@ -96,7 +98,7 @@ def assert_class_method(method, content, &block)
# end
# end
def assert_instance_method(method, content)
assert content =~ /(\s+)def #{method}(\(.+\))?(.*?)\n\1end/m, "Expected to have method #{method}"
assert content =~ METHOD_DECLARATION_REGEXP, "Expected to have method #{method}"
yield $3.strip if block_given?
end
alias :assert_method :assert_instance_method