mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
22a1a5ac8c
Squashed commit of the following: commit 96991e8e919edfb20cc4120bca4e36ed51175d57 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:29:24 2014 -0800 Revert "gems can be added or skipped from the template" This reverts commit8beb42cfbc
. Conflicts: railties/lib/rails/generators/rails/app/app_generator.rb railties/test/generators/app_generator_test.rb commit 35599c0e657245ef14ac0f28c9189ad16acf40e6 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:26:53 2014 -0800 Revert "oops, template replay needs to happen after bundle. :orz:" This reverts commit9104702be6
. Conflicts: railties/lib/rails/generators/rails/app/app_generator.rb commit f519c3902c313db8e906a49251c91643b8e6499e Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:25:51 2014 -0800 Revert "only ask for these ivars if the target responds to them" This reverts commit656d412546
. commit aa524a9428e3e4c45fe221f10a66a08efb827ab5 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:25:39 2014 -0800 Revert "refactor generator tests to use block form of Tempfile" This reverts commit65251820ef
. commit 7d3740549fa4dfa62e3761f8d4bc6d6d441256e7 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:25:25 2014 -0800 Revert "add a more restricted codepath for templates fixes #13390" This reverts commit2875b4a66e
. commit 525df0af1001918986cdfce59539fd2d52c4f32c Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri Feb 14 11:25:11 2014 -0800 Revert "add a send so `apply` can be called. Fixes #13510" This reverts commitc5034d60db
.
85 lines
2.7 KiB
Ruby
85 lines
2.7 KiB
Ruby
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
|
|
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
|
|
def gemfile_entry(*args); super; end
|
|
})
|
|
end
|
|
end
|
|
|
|
def test_construction
|
|
klass = make_builder_class
|
|
assert klass.start(['new', 'blah'])
|
|
end
|
|
|
|
def test_add_gem
|
|
klass = make_builder_class
|
|
generator = klass.start(['new', 'blah'])
|
|
generator.gemfile_entry 'tenderlove'
|
|
assert_includes generator.gemfile_entries.map(&:name), 'tenderlove'
|
|
end
|
|
|
|
def test_add_gem_with_version
|
|
klass = make_builder_class
|
|
generator = klass.start(['new', 'blah'])
|
|
generator.gemfile_entry 'tenderlove', '2.0.0'
|
|
assert generator.gemfile_entries.find { |gfe|
|
|
gfe.name == 'tenderlove' && gfe.version == '2.0.0'
|
|
}
|
|
end
|
|
|
|
def test_add_github_gem
|
|
klass = make_builder_class
|
|
generator = klass.start(['new', 'blah'])
|
|
generator.gemfile_entry 'tenderlove', github: 'hello world'
|
|
assert generator.gemfile_entries.find { |gfe|
|
|
gfe.name == 'tenderlove' && gfe.options[:github] == 'hello world'
|
|
}
|
|
end
|
|
|
|
def test_add_path_gem
|
|
klass = make_builder_class
|
|
generator = klass.start(['new', 'blah'])
|
|
generator.gemfile_entry 'tenderlove', path: 'hello world'
|
|
assert generator.gemfile_entries.find { |gfe|
|
|
gfe.name == 'tenderlove' && gfe.options[:path] == 'hello world'
|
|
}
|
|
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
|