diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-10-20 01:05:34 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-11-02 17:14:50 +0100 |
commit | bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6 (patch) | |
tree | 66cb8d9e83caf74e8f2aed00f412d419d1f46042 /railties/test/generators | |
parent | b8a0fabe184f6c8f926f7869341ca40b6395606a (diff) | |
download | rails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.tar.gz rails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.tar.bz2 rails-bcd414fd10a0e401cfb1de95cc9b2940b1df0ff6.zip |
Add support for templates for rails plugin new
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index fa00e75132..f3672cb6f1 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -110,6 +110,26 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_match /STEP 2.*create Gemfile/m, output end + def test_template_from_dir_pwd + FileUtils.cd(Rails.root) + assert_match /It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]) + end + + def test_template_raises_an_error_with_invalid_path + content = capture(:stderr){ run_generator([destination_root, "-m", "non/existant/path"]) } + assert_match /The template \[.*\] could not be loaded/, content + assert_match /non\/existant\/path/, content + end + + def test_template_is_executed_when_supplied + path = "http://gist.github.com/103208.txt" + template = %{ say "It works!" } + template.instance_eval "def read; self; end" # Make the string respond to read + + generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) + assert_match /It works!/, silence(:stdout){ generator.invoke_all } + end + protected def action(*args, &block) |