diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-31 11:48:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-31 11:48:12 -0700 |
commit | 90ace1b9863675f26a0b9fce4de3b95388cd1a35 (patch) | |
tree | c074785d843fc9eec70851af2bde298da2bb214b /railties | |
parent | 4d4ff531b8807ee88a3fc46875c7e76f613956fb (diff) | |
download | rails-90ace1b9863675f26a0b9fce4de3b95388cd1a35.tar.gz rails-90ace1b9863675f26a0b9fce4de3b95388cd1a35.tar.bz2 rails-90ace1b9863675f26a0b9fce4de3b95388cd1a35.zip |
forgot to add the test. orz :cry:
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/generators/generator_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/railties/test/generators/generator_test.rb b/railties/test/generators/generator_test.rb new file mode 100644 index 0000000000..7600a40ae9 --- /dev/null +++ b/railties/test/generators/generator_test.rb @@ -0,0 +1,50 @@ +require 'active_support/test_case' +require 'active_support/testing/autorun' +require 'rails/generators/app_base' + +module Rails + module Generators + class GeneratorTest < ActiveSupport::TestCase + def make_builder_class + klass = Class.new(AppBase) do + add_shared_options_for "application" + + # include a module to get around thor's method_added hook + include(Module.new { + def gemfile_entries; super; end + def invoke_all; super; self; end + def add_gem_entry_filter; super; end + }) + end + end + + def test_construction + klass = make_builder_class + assert klass.start(['new', 'blah']) + end + + def test_filter + klass = make_builder_class + generator = klass.start(['new', 'blah']) + gems = generator.gemfile_entries + generator.add_gem_entry_filter { |gem| + gem.name != gems.first.name + } + assert_equal gems.drop(1), generator.gemfile_entries + end + + def test_two_filters + klass = make_builder_class + generator = klass.start(['new', 'blah']) + gems = generator.gemfile_entries + generator.add_gem_entry_filter { |gem| + gem.name != gems.first.name + } + generator.add_gem_entry_filter { |gem| + gem.name != gems[1].name + } + assert_equal gems.drop(2), generator.gemfile_entries + end + end + end +end |