Permalink
Browse files

Refactor generator methods

  • Loading branch information...
1 parent 4e1da15 commit 3e59eb4f624a2ffd8dfce3d96fa4644385d2e6ed @elskwid elskwid committed Jan 26, 2013
View
0 ...tors/thincloud/test/templates/capybara.rb → ...ncloud/test/templates/support/capybara.rb
File renamed without changes.
View
0 ...ncloud/test/templates/database_cleaner.rb → ...est/templates/support/database_cleaner.rb
File renamed without changes.
View
0 .../thincloud/test/templates/factory_girl.rb → ...ud/test/templates/support/factory_girl.rb
File renamed without changes.
View
0 ...hincloud/test/templates/minitest_rails.rb → .../test/templates/support/minitest_rails.rb
File renamed without changes.
View
0 ...loud/test/templates/minitest_reporters.rb → ...t/templates/support/minitest_reporters.rb
File renamed without changes.
View
0 .../thincloud/test/templates/routing_spec.rb → ...ud/test/templates/support/routing_spec.rb
File renamed without changes.
View
61 lib/generators/thincloud/test/test_generator.rb
@@ -7,51 +7,68 @@ class TestGenerator < ::Rails::Generators::Base
desc "Generates thincloud test infrastructure."
def test
- generate "mini_test:install"
+ setup_minitest_rails
- empty_directory "test/factories"
- create_file "test/factories/.gitkeep"
-
- remove_file "test/minitest_helper.rb"
- copy_file "minitest_helper_rails.rb", "test/minitest_helper.rb"
+ directory "support", "test/support"
- copy_file "capybara.rb", "test/support/capybara.rb"
- copy_file "factory_girl.rb", "test/support/factory_girl.rb"
- copy_file "database_cleaner.rb", "test/support/database_cleaner.rb"
- copy_file "minitest_rails.rb", "test/support/minitest_rails.rb"
- copy_file "minitest_reporters.rb", "test/support/minitest_reporters.rb"
- copy_file "routing_spec.rb", "test/support/routing_spec.rb"
copy_file "test.rake", "lib/tasks/test.rake"
copy_file "Guardfile"
- create_file ".gitignore" unless File.exist?(".gitignore")
- append_file ".gitignore", "coverage"
+ update_gitignore
say_status "", ""
say_status "success", "thincloud-test has finished."
end
# Generates thincloud test infrastructure outside of Rails
def standalone
- remove_file "test/test_helper.rb"
+ setup_minitest
+
+ copy_file "support/minitest_reporters.rb",
+ "test/support/minitest_reporters.rb"
- copy_file "minitest_helper_standalone.rb", "test/minitest_helper.rb"
- copy_file "minitest_reporters.rb", "test/support/minitest_reporters.rb"
copy_file "test.rake", "lib/tasks/test.rake"
+
copy_file "Guardfile"
+ setup_ci
+
+ update_gitignore
+
+ say_status "", ""
+ say_status "success", "thincloud-test standalone has finished."
+ say_status "", "Customize .travis.yml and test/ci/* for your project."
+ end
+
+
+ private
+
+ def update_gitignore
+ create_file ".gitignore" unless File.exist?(".gitignore")
+ append_file ".gitignore", "coverage"
+ end
+
+ def setup_ci
empty_directory "test/ci"
copy_file "ci/before_script.sh", "test/ci/before_script.sh"
copy_file "ci/ci_runner.sh", "test/ci/ci_runner.sh"
copy_file "ci/travis.yml", ".travis.yml"
+ end
- create_file ".gitignore" unless File.exist?(".gitignore")
- append_file ".gitignore", "coverage"
+ def setup_minitest_rails
+ generate "mini_test:install"
+ remove_file "test/minitest_helper.rb"
- say_status "", ""
- say_status "success", "thincloud-test has finished."
- say_status "", "Customize .travis.yml and test/ci/* for your project."
+ copy_file "minitest_helper_rails.rb", "test/minitest_helper.rb"
+
+ empty_directory "test/factories"
+ create_file "test/factories/.gitkeep"
+ end
+
+ def setup_minitest
+ remove_file "test/test_helper.rb"
+ copy_file "minitest_helper_standalone.rb", "test/minitest_helper.rb"
end
end

0 comments on commit 3e59eb4

Please sign in to comment.