diff --git a/Library/Homebrew/cask/spec/cask/system_command_result_spec.rb b/Library/Homebrew/cask/spec/cask/system_command_result_spec.rb new file mode 100644 index 0000000000..7eb4fb722d --- /dev/null +++ b/Library/Homebrew/cask/spec/cask/system_command_result_spec.rb @@ -0,0 +1,49 @@ +require "spec_helper" + +describe Hbc::SystemCommand::Result do + describe "::_parse_plist" do + let(:command) { Hbc::SystemCommand.new("/usr/bin/true", {}) } + let(:hdiutil_output) { + <<-EOS.undent + Hello there! I am in no way XML am I?!?! + + That's a little silly... you were expexting XML here! + + What is a parser to do? + + Hopefully explode! + + + + + + system-entities + + + content-hint + Apple_HFS + dev-entry + /dev/disk3s2 + mount-point + /private/tmp/dmg.BhfS2g + potentially-mountable + + unmapped-content-hint + Apple_HFS + volume-kind + hfs + + + + + EOS + } + + it "ignores garbage output before xml starts" do + parsed = described_class._parse_plist(command, hdiutil_output) + + expect(parsed.keys).to eq(["system-entities"]) + expect(parsed["system-entities"].length).to eq(1) + end + end +end diff --git a/Library/Homebrew/cask/test/plist/parser_test.rb b/Library/Homebrew/cask/test/plist/parser_test.rb index a73d1f7f58..173541a727 100644 --- a/Library/Homebrew/cask/test/plist/parser_test.rb +++ b/Library/Homebrew/cask/test/plist/parser_test.rb @@ -2,51 +2,51 @@ require "test_helper" describe Plist do it "parses some hdiutil output okay" do - hdiutil_output = <<-HDIUTILOUTPUT - - - - - system-entities - - - content-hint - Apple_partition_map - dev-entry - /dev/disk3s1 - potentially-mountable - - unmapped-content-hint - Apple_partition_map - - - content-hint - Apple_partition_scheme - dev-entry - /dev/disk3 - potentially-mountable - - unmapped-content-hint - Apple_partition_scheme - - - content-hint - Apple_HFS - dev-entry - /dev/disk3s2 - mount-point - /private/tmp/dmg.BhfS2g - potentially-mountable - - unmapped-content-hint - Apple_HFS - volume-kind - hfs - - - - - HDIUTILOUTPUT + hdiutil_output = <<-EOS.undent + + + + + system-entities + + + content-hint + Apple_partition_map + dev-entry + /dev/disk3s1 + potentially-mountable + + unmapped-content-hint + Apple_partition_map + + + content-hint + Apple_partition_scheme + dev-entry + /dev/disk3 + potentially-mountable + + unmapped-content-hint + Apple_partition_scheme + + + content-hint + Apple_HFS + dev-entry + /dev/disk3s2 + mount-point + /private/tmp/dmg.BhfS2g + potentially-mountable + + unmapped-content-hint + Apple_HFS + volume-kind + hfs + + + + + EOS parsed = Plist.parse_xml(hdiutil_output) @@ -59,47 +59,6 @@ describe Plist do ] end - it "can ignore garbage output before xml starts" do - hdiutil_output = <<-HDIUTILOUTPUT -Hello there! I am in no way XML am I?!?! - - That's a little silly... you were expexting XML here! - -What is a parser to do? - -Hopefully explode! - - - - - - system-entities - - - content-hint - Apple_HFS - dev-entry - /dev/disk3s2 - mount-point - /private/tmp/dmg.BhfS2g - potentially-mountable - - unmapped-content-hint - Apple_HFS - volume-kind - hfs - - - - - HDIUTILOUTPUT - - parsed = Plist.parse_xml(hdiutil_output) - - parsed.keys.must_equal ["system-entities"] - parsed["system-entities"].length.must_equal 1 - end - it "does not choke on empty input" do Plist.parse_xml("").must_equal {} end