From d81af187eae3b4cc961b785d83899b1545db0127 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Jan 2014 12:13:54 -0800 Subject: [PATCH] core: add tests for MachineReadable and frozen strings --- test/unit/vagrant/ui_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unit/vagrant/ui_test.rb b/test/unit/vagrant/ui_test.rb index c30935715..58da18e37 100644 --- a/test/unit/vagrant/ui_test.rb +++ b/test/unit/vagrant/ui_test.rb @@ -199,6 +199,19 @@ describe Vagrant::UI::MachineReadable do subject.machine(:type, "foo\nbar\r") end + + # This is for a bug where JSON parses are frozen and an + # exception was being raised. + it "works properly with frozen string arguments" do + subject.should_receive(:safe_puts).with do |message| + parts = message.split(",") + expect(parts.length).to eq(4) + expect(parts[3]).to eq("foo\\nbar\\r") + true + end + + subject.machine(:type, "foo\nbar\r".freeze) + end end end