Shell UI tests. Added option to not translate. Updated non-translated strings.
This commit is contained in:
parent
ce080e908f
commit
7ddff513f0
|
@ -7,7 +7,8 @@ env = Vagrant::Environment.load!
|
|||
begin
|
||||
Vagrant::CLI.start(ARGV, :env => env)
|
||||
rescue Vagrant::Errors::VagrantError => e
|
||||
env.ui.error e.message, false
|
||||
env.ui.error e.backtrace.join("\n"), false if ENV["VAGRANT_DEBUG"]
|
||||
opts = { :_translate => false, :_prefix => false }
|
||||
env.ui.error e.message, opts
|
||||
env.ui.error e.backtrace.join("\n"), opts if ENV["VAGRANT_DEBUG"]
|
||||
exit e.status_code
|
||||
end
|
||||
|
|
|
@ -25,8 +25,8 @@ module Vagrant
|
|||
desc "list", "Lists all installed boxes"
|
||||
def list
|
||||
boxes = Box.all(env).sort
|
||||
return env.ui.warn("vagrant.commands.box.no_installed_boxes", :_prefix => false)# if boxes.empty?
|
||||
boxes.each { |b| env.ui.info(b) }
|
||||
return env.ui.warn("vagrant.commands.box.no_installed_boxes", :_prefix => false) if boxes.empty?
|
||||
boxes.each { |b| env.ui.info(b, :_translate => false, :_prefix => false) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module Vagrant
|
|||
ssh_vm.ssh.execute do |ssh|
|
||||
ssh_vm.env.ui.info "vagrant.commands.ssh.execute", :command => options[:execute]
|
||||
ssh.exec!(options[:execute]) do |channel, type, data|
|
||||
ssh_vm.env.ui.info "#{data}"
|
||||
ssh_vm.env.ui.info "#{data}", :_translate => false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ module Vagrant
|
|||
vm = target_vms.first
|
||||
raise VMNotCreatedError.new if !vm.created?
|
||||
|
||||
env.ui.info Util::TemplateRenderer.render("ssh_config", {
|
||||
env.ui.info(Util::TemplateRenderer.render("ssh_config", {
|
||||
:host_key => options[:host] || "vagrant",
|
||||
:ssh_user => vm.env.config.ssh.username,
|
||||
:ssh_port => vm.ssh.port,
|
||||
:private_key_path => vm.env.config.ssh.private_key_path
|
||||
})
|
||||
}), :_translate => false, :_prefix => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module Vagrant
|
|||
if type == :exit_status
|
||||
ssh.check_exit_status(data, command)
|
||||
else
|
||||
env.ui.info("#{data}: #{type}")
|
||||
env.ui.info("#{data}: #{type}", :_translate => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ module Vagrant
|
|||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!(command) do |channel, type, data|
|
||||
ssh.check_exit_status(data, command) if type == :exit_status
|
||||
env.ui.info("#{data}: #{type}") if type != :exit_status
|
||||
env.ui.info("#{data}: #{type}", :_translate => false) if type != :exit_status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,9 +26,9 @@ module Vagrant
|
|||
end
|
||||
|
||||
[[:warn, :yellow], [:error, :red], [:info, nil], [:confirm, :green]].each do |method, color|
|
||||
define_method(method) do |key, opts=nil|
|
||||
opts = { :_prefix => true }.merge(opts || {})
|
||||
message = I18n.t(key, opts)
|
||||
define_method(method) do |message, opts=nil|
|
||||
opts = { :_prefix => true, :_translate => true }.merge(opts || {})
|
||||
message = I18n.t(message, opts) if opts[:_translate]
|
||||
message = format_message(message) if opts[:_prefix]
|
||||
@shell.say("#{line_reset}#{message}", color)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
require "test_helper"
|
||||
|
||||
class ShellUITest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::UI::Shell
|
||||
@shell = mock("shell")
|
||||
@instance = @klass.new(mock_environment, @shell)
|
||||
end
|
||||
|
||||
context "prefixing with resource" do
|
||||
should "prefix message with environment resource" do
|
||||
@shell.expects(:say).with() do |message, color|
|
||||
assert message =~ /\[#{@instance.env.resource}\]/
|
||||
true
|
||||
end
|
||||
|
||||
@instance.info("vagrant.errors.test_key")
|
||||
end
|
||||
|
||||
should "not prefix the message if given false" do
|
||||
@shell.expects(:say).with() do |message, color|
|
||||
assert message !~ /\[#{@instance.env.resource}\]/
|
||||
true
|
||||
end
|
||||
|
||||
@instance.info("vagrant.errors.test_key", :_prefix => false)
|
||||
end
|
||||
end
|
||||
|
||||
context "translating" do
|
||||
should "translate the message by default" do
|
||||
@shell.expects(:say).with() do |message, color|
|
||||
assert message.include?(I18n.t("vagrant.errors.test_key"))
|
||||
true
|
||||
end
|
||||
|
||||
@instance.info("vagrant.errors.test_key")
|
||||
end
|
||||
|
||||
should "not translate the message if noted" do
|
||||
@shell.expects(:say).with() do |message, color|
|
||||
assert message.include?("vagrant.errors.test_key")
|
||||
true
|
||||
end
|
||||
|
||||
@instance.info("vagrant.errors.test_key", :_translate => false)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue