"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/test/unit/plugins/guests/darwin/cap/darwin_version_test.rb" (20 Nov 2020, 1276 Bytes) of package /linux/misc/vagrant-2.2.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 require_relative "../../../../base"
    2 
    3 describe "VagrantPlugins::GuestDarwin::Cap::DarwinVersion" do
    4   let(:caps) do
    5     VagrantPlugins::GuestDarwin::Plugin
    6       .components
    7       .guest_capabilities[:darwin]
    8   end
    9 
   10   let(:machine) { double("machine") }
   11   let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
   12 
   13   before do
   14     allow(machine).to receive(:communicate).and_return(comm)
   15   end
   16 
   17   after do
   18     comm.verify_expectations!
   19   end
   20 
   21   describe ".darwin_version" do
   22     let(:cap) { caps.get(:darwin_version) }
   23 
   24     {
   25       "kern.osrelease: 19.6.0" => "19.6.0",
   26       "kern.osrelease: 20.1.10" => "20.1.10",
   27     }.each do |str, expected|
   28       it "returns #{expected} for #{str}" do
   29         comm.stub_command("sysctl kern.osrelease", stdout: str)
   30         expect(cap.darwin_version(machine)).to eq(expected)
   31       end
   32     end
   33   end
   34 
   35   describe ".darwin_major_version" do
   36     let(:cap) { caps.get(:darwin_major_version) }
   37 
   38     {
   39       "kern.osrelease: 19.6.0" => 19,
   40       "kern.osrelease: 20.1.10" => 20,
   41       "" => nil
   42     }.each do |str, expected|
   43       it "returns #{expected} for #{str}" do
   44         comm.stub_command("sysctl kern.osrelease", stdout: str)
   45         expect(cap.darwin_major_version(machine)).to eq(expected)
   46       end
   47     end
   48   end
   49 end