2009-06-25 04:18:00 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
require 'generators/generators_test_helper'
|
|
|
|
require 'generators/rails/plugin/plugin_generator'
|
|
|
|
|
|
|
|
class PluginGeneratorTest < GeneratorsTestCase
|
|
|
|
|
|
|
|
def test_plugin_skeleton_is_created
|
|
|
|
run_generator
|
|
|
|
|
|
|
|
%w(
|
|
|
|
vendor/plugins
|
|
|
|
vendor/plugins/plugin_fu
|
|
|
|
vendor/plugins/plugin_fu/lib
|
|
|
|
).each{ |path| assert_file path }
|
|
|
|
end
|
|
|
|
|
2009-06-25 05:56:18 -04:00
|
|
|
def test_check_class_collision
|
|
|
|
content = capture(:stderr){ run_generator ["object"] }
|
|
|
|
assert_match /The name 'Object' is either already used in your application or reserved/, content
|
|
|
|
end
|
|
|
|
|
2009-06-25 04:18:00 -04:00
|
|
|
def test_invokes_default_test_framework
|
|
|
|
run_generator
|
2009-06-29 13:56:22 -04:00
|
|
|
assert_file "vendor/plugins/plugin_fu/test/plugin_fu_test.rb", /class PluginFuTest < ActiveSupport::TestCase/
|
|
|
|
assert_file "vendor/plugins/plugin_fu/test/test_helper.rb"
|
2009-06-25 04:18:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_logs_if_the_test_framework_cannot_be_found
|
2009-07-08 06:55:50 -04:00
|
|
|
content = run_generator ["plugin_fu", "--test-framework=rspec"]
|
|
|
|
assert_match /rspec \[not found\]/, content
|
2009-06-25 04:18:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_creates_tasks_if_required
|
2009-07-03 06:10:09 -04:00
|
|
|
run_generator ["plugin_fu", "--tasks"]
|
2009-06-25 04:18:00 -04:00
|
|
|
assert_file "vendor/plugins/plugin_fu/tasks/plugin_fu_tasks.rake"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_creates_generator_if_required
|
2009-07-03 06:10:09 -04:00
|
|
|
run_generator ["plugin_fu", "--generator"]
|
2009-07-03 06:19:22 -04:00
|
|
|
assert_file "vendor/plugins/plugin_fu/lib/generators/templates"
|
|
|
|
assert_file "vendor/plugins/plugin_fu/lib/generators/plugin_fu_generator.rb",
|
|
|
|
/class PluginFuGenerator < Rails::Generators::NamedBase/
|
2009-06-25 04:18:00 -04:00
|
|
|
end
|
|
|
|
|
2009-07-01 16:06:05 -04:00
|
|
|
def test_plugin_generator_on_revoke
|
|
|
|
run_generator
|
|
|
|
run_generator ["plugin_fu"], :behavior => :revoke
|
|
|
|
end
|
|
|
|
|
2009-06-25 04:18:00 -04:00
|
|
|
protected
|
|
|
|
|
2009-07-01 16:06:05 -04:00
|
|
|
def run_generator(args=["plugin_fu"], config={})
|
2009-07-14 16:20:43 -04:00
|
|
|
silence(:stdout) { Rails::Generators::PluginGenerator.start args, config.merge(:destination_root => destination_root) }
|
2009-06-25 04:18:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|