From b36fa51a3f56431d8e46c1fff6a6493d3c10607a Mon Sep 17 00:00:00 2001
From: Piotr Sarnacki <drogus@gmail.com>
Date: Wed, 20 Oct 2010 21:21:14 +0200
Subject: Allow easy overriding of test framework in 'rake plugin new'
 generator, using PluginBuilder

---
 railties/test/fixtures/lib/plugin_builders/spec_builder.rb | 13 +++++++++++++
 railties/test/generators/plugin_new_generator_test.rb      | 10 ++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 railties/test/fixtures/lib/plugin_builders/spec_builder.rb

(limited to 'railties/test')

diff --git a/railties/test/fixtures/lib/plugin_builders/spec_builder.rb b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb
new file mode 100644
index 0000000000..bdaa1fb8e1
--- /dev/null
+++ b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb
@@ -0,0 +1,13 @@
+class PluginBuilder < Rails::PluginBuilder
+  def test
+    create_file "spec/spec_helper.rb"
+  end
+
+  def test_path
+    "spec"
+  end
+
+  def rakefile_test_tasks
+    "# spec tasks in rakefile"
+  end
+end
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index 0d88d36971..a7177914e1 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -217,6 +217,16 @@ class CustomPluginGeneratorTest < Rails::Generators::TestCase
     DEFAULT_PLUGIN_FILES.each{ |path| assert_no_file path }
   end
 
+  def test_overriding_test_framework
+    FileUtils.cd(destination_root)
+    run_generator([destination_root, "-b", "#{Rails.root}/lib/plugin_builders/spec_builder.rb"])
+    assert_file 'spec/spec_helper.rb'
+    assert_file 'Rakefile', /task :default => :spec/
+    assert_file 'Rakefile', /# spec tasks in rakefile/
+    assert_file 'spec/dummy'
+    assert_file 'script/rails', %r{spec/dummy}
+  end
+
 protected
 
   def action(*args, &block)
-- 
cgit v1.2.3