diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-01 13:06:38 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-01 13:06:38 -0300 |
commit | b2f62f54f560490f337e0c22755922283e4c3557 (patch) | |
tree | cc5602615c5d930a1db67fa1da61ca1d6d960a20 /railties | |
parent | 5f370eb0fff244c475c412007c32d8b03fb1c3c6 (diff) | |
download | rails-b2f62f54f560490f337e0c22755922283e4c3557.tar.gz rails-b2f62f54f560490f337e0c22755922283e4c3557.tar.bz2 rails-b2f62f54f560490f337e0c22755922283e4c3557.zip |
Move the class methods to above the protected section
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/testing/assertions.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/generators/testing/behaviour.rb | 76 | ||||
-rw-r--r-- | railties/lib/rails/generators/testing/setup_and_teardown.rb | 4 |
3 files changed, 36 insertions, 47 deletions
diff --git a/railties/lib/rails/generators/testing/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb index ee47e28983..6267b2f2ee 100644 --- a/railties/lib/rails/generators/testing/assertions.rb +++ b/railties/lib/rails/generators/testing/assertions.rb @@ -1,9 +1,7 @@ module Rails module Generators module Testing - module Assertions - # Asserts a given file exists. You need to supply an absolute path or a path relative # to the configured destination: # @@ -118,7 +116,6 @@ module Rails assert_equal(value, create_generated_attribute(attribute_type).default) end end - end end end diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb index a90296f697..caad810de8 100644 --- a/railties/lib/rails/generators/testing/behaviour.rb +++ b/railties/lib/rails/generators/testing/behaviour.rb @@ -8,7 +8,6 @@ require 'rails/generators' module Rails module Generators module Testing - module Behaviour extend ActiveSupport::Concern @@ -21,6 +20,29 @@ module Rails self.default_arguments = [] end + module ClassMethods + # Sets which generator should be tested: + # + # tests AppGenerator + def tests(klass) + self.generator_class = klass + end + + # Sets default arguments on generator invocation. This can be overwritten when + # invoking it. + # + # arguments %w(app_name --skip-active-record) + def arguments(array) + self.default_arguments = array + end + + # Sets the destination of generator files: + # + # destination File.expand_path("../tmp", File.dirname(__FILE__)) + def destination(path) + self.destination_root = path + end + end # Runs the generator configured for this class. The first argument is an array like # command line arguments: @@ -55,53 +77,27 @@ module Rails Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':')) end - protected - - def destination_root_is_set? # :nodoc: - raise "You need to configure your Rails::Generators::TestCase destination root." unless destination_root - end - - def ensure_current_path # :nodoc: - cd current_path - end - - def prepare_destination # :nodoc: - rm_rf(destination_root) - mkdir_p(destination_root) - end - - def migration_file_name(relative) # :nodoc: - absolute = File.expand_path(relative, destination_root) - dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '') - Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first - end + protected + def destination_root_is_set? # :nodoc: + raise "You need to configure your Rails::Generators::TestCase destination root." unless destination_root + end - module ClassMethods - # Sets which generator should be tested: - # - # tests AppGenerator - def tests(klass) - self.generator_class = klass + def ensure_current_path # :nodoc: + cd current_path end - # Sets default arguments on generator invocation. This can be overwritten when - # invoking it. - # - # arguments %w(app_name --skip-active-record) - def arguments(array) - self.default_arguments = array + def prepare_destination # :nodoc: + rm_rf(destination_root) + mkdir_p(destination_root) end - # Sets the destination of generator files: - # - # destination File.expand_path("../tmp", File.dirname(__FILE__)) - def destination(path) - self.destination_root = path + def migration_file_name(relative) # :nodoc: + absolute = File.expand_path(relative, destination_root) + dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '') + Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first end - end end - end end end diff --git a/railties/lib/rails/generators/testing/setup_and_teardown.rb b/railties/lib/rails/generators/testing/setup_and_teardown.rb index 0eb163eab7..73102a283f 100644 --- a/railties/lib/rails/generators/testing/setup_and_teardown.rb +++ b/railties/lib/rails/generators/testing/setup_and_teardown.rb @@ -1,9 +1,7 @@ module Rails module Generators module Testing - module SetupAndTeardown - def setup # :nodoc: destination_root_is_set? ensure_current_path @@ -14,9 +12,7 @@ module Rails ensure_current_path super end - end - end end end |