require "spec_helper" describe Plist do subject { described_class.parse_xml(input) } describe "::parse_xml" do context "given a hdiutil output as input" do let(:input) { <<-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 } it "successfully parses it" do expect(subject.keys).to eq(["system-entities"]) expect(subject["system-entities"].length).to eq(3) expect(subject["system-entities"].map { |e| e["dev-entry"] }).to eq( %w[ /dev/disk3s1 /dev/disk3 /dev/disk3s2 ], ) end end context "given an empty input" do let(:input) { "" } it { is_expected.to be_nil } end end end