diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-12 16:51:21 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-12 16:51:21 -0700 |
commit | 81f243375b9d3cfd431c1ca904c5c1efc9a41ae8 (patch) | |
tree | a7556fbfa8431e4c1adb8a11970a360e5ffaa6df | |
parent | c7673b0981d961e5510c85d958c944876d543314 (diff) | |
parent | 83d0232304a16fc7431b6778f80e42cc073b3600 (diff) | |
download | rails-81f243375b9d3cfd431c1ca904c5c1efc9a41ae8.tar.gz rails-81f243375b9d3cfd431c1ca904c5c1efc9a41ae8.tar.bz2 rails-81f243375b9d3cfd431c1ca904c5c1efc9a41ae8.zip |
Merge pull request #10194 from pabloh/extract_regexp_at_generators_testing_assertion
Extract method declaration regexp for assert_method into a constant
-rw-r--r-- | railties/lib/rails/generators/testing/assertions.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/testing/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb index 6267b2f2ee..14fd4efd4e 100644 --- a/railties/lib/rails/generators/testing/assertions.rb +++ b/railties/lib/rails/generators/testing/assertions.rb @@ -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 @@ module Rails # 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 |