core: Ui#dup works properly

This commit is contained in:
Mitchell Hashimoto 2014-02-08 15:11:51 -08:00
parent 9026e54da9
commit 2d7c161f49
2 changed files with 17 additions and 0 deletions

View File

@ -26,6 +26,11 @@ module Vagrant
@opts = {}
end
def initialize_copy(original)
super
@opts = original.opts.dup
end
[:ask, :detail, :warn, :error, :info, :output, :success].each do |method|
define_method(method) do |message, *opts|
# Log normal console messages
@ -214,6 +219,11 @@ module Vagrant
@ui = ui
end
def initialize_copy(original)
super
@ui = original.instance_variable_get(:@ui).dup
end
# Use some light meta-programming to create the various methods to
# output text to the UI. These all delegate the real functionality
# to `say`.

View File

@ -237,6 +237,13 @@ describe Vagrant::UI::Prefixed do
subject { described_class.new(ui, prefix) }
describe "#initialize_copy" do
it "duplicates the underlying ui too" do
another = subject.dup
expect(another.opts).to_not equal(subject.opts)
end
end
describe "#ask" do
it "does not request bolding" do
ui.should_receive(:ask).with(" #{prefix}: foo", bold: false)