1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/generators/plugin_generator_test.rb

72 lines
2.4 KiB
Ruby
Raw Normal View History

2009-06-25 04:18:00 -04:00
require 'generators/generators_test_helper'
require 'rails/generators/rails/plugin/plugin_generator'
2009-06-25 04:18:00 -04:00
class PluginGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(plugin_fu)
2009-06-25 04:18:00 -04:00
def test_plugin_skeleton_is_created
2010-11-14 20:27:06 -05:00
silence(:stderr) { run_generator }
2010-01-17 09:17:50 -05:00
year = Date.today.year
2009-06-25 04:18:00 -04:00
%w(
vendor/plugins
vendor/plugins/plugin_fu
2010-01-17 09:17:50 -05:00
vendor/plugins/plugin_fu/init.rb
vendor/plugins/plugin_fu/install.rb
vendor/plugins/plugin_fu/uninstall.rb
2009-06-25 04:18:00 -04:00
vendor/plugins/plugin_fu/lib
2010-01-17 09:17:50 -05:00
vendor/plugins/plugin_fu/lib/plugin_fu.rb
vendor/plugins/plugin_fu/Rakefile
2009-06-25 04:18:00 -04:00
).each{ |path| assert_file path }
2010-01-17 09:17:50 -05:00
%w(
vendor/plugins/plugin_fu/README
).each{ |path| assert_file path, /PluginFu/ }
%w(
vendor/plugins/plugin_fu/README
vendor/plugins/plugin_fu/MIT-LICENSE
).each{ |path| assert_file path, /#{year}/ }
2009-06-25 04:18:00 -04:00
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
2010-11-14 20:27:06 -05:00
silence(:stderr) { 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
2010-11-14 20:27:06 -05:00
content = nil
silence(:stderr) { 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
2010-11-14 20:27:06 -05:00
silence(:stderr) { run_generator ["plugin_fu", "--tasks"] }
assert_file "vendor/plugins/plugin_fu/lib/tasks/plugin_fu_tasks.rake"
2009-06-25 04:18:00 -04:00
end
def test_creates_generator_if_required
2010-11-14 20:27:06 -05:00
silence(:stderr) { run_generator ["plugin_fu", "--generator"] }
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
2010-11-14 20:27:06 -05:00
silence(:stderr) { run_generator }
2009-07-01 16:06:05 -04:00
run_generator ["plugin_fu"], :behavior => :revoke
end
2010-11-14 20:27:06 -05:00
def test_deprecation
output = capture(:stderr) { run_generator }
assert_match /Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure./, output
2010-11-14 20:27:06 -05:00
end
2009-06-25 04:18:00 -04:00
end