提交 44633dc7 编写于 作者: J José Valim

Add some tests for no_color! behavior.

上级 21db0481
......@@ -7,4 +7,4 @@
end
name = ARGV.shift
Rails::Generators.invoke name, ARGV, :revoke
Rails::Generators.invoke name, ARGV, :behavior => :revoke
......@@ -7,4 +7,4 @@
end
name = ARGV.shift
Rails::Generators.invoke name, ARGV, :invoke
Rails::Generators.invoke name, ARGV, :behavior => :invoke
......@@ -7,4 +7,4 @@
end
name = ARGV.shift
Rails::Generators.invoke name, ARGV, :skip
Rails::Generators.invoke name, ARGV, :behavior => :skip
......@@ -123,10 +123,10 @@ def self.help
# It's used as the default entry point for generate, destroy and update
# commands.
#
def self.invoke(namespace, args=ARGV, behavior=:invoke)
def self.invoke(namespace, args=ARGV, config={})
if klass = find_by_namespace(namespace, "rails")
args << "--help" if klass.arguments.any? { |a| a.required? } && args.empty?
klass.start args, :behavior => behavior
klass.start args, config
else
puts "Could not find generator #{namespace}."
end
......
......@@ -13,14 +13,14 @@ def test_help_when_a_generator_with_required_arguments_is_invoked_without_argume
assert_match /Description:/, output
end
def test_invoke_with_default_behavior
Rails::Generators::ModelGenerator.expects(:start).with(["Account"], :behavior => :invoke)
def test_invoke_with_default_values
Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {})
Rails::Generators.invoke :model, ["Account"]
end
def test_invoke_with_given_behavior
def test_invoke_with_config_values
Rails::Generators::ModelGenerator.expects(:start).with(["Account"], :behavior => :skip)
Rails::Generators.invoke :model, ["Account"], :skip
Rails::Generators.invoke :model, ["Account"], :behavior => :skip
end
def test_find_by_namespace_without_base_or_context
......@@ -77,4 +77,11 @@ def test_rails_generators_with_others_information
output = capture(:stdout){ Rails::Generators.help }.split("\n").last
assert_equal "Others: active_record:fixjour, fixjour, rails:javascripts.", output
end
def test_no_color_sets_proper_shell
Rails::Generators.no_color!
assert_equal Thor::Shell::Basic, Thor::Base.shell
ensure
Thor::Base.shell = Thor::Shell::Color
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册