Sha256: 77d8520c7655ed7a89076b2d807c70cd3d30f642a32f086ccc4ab4728e560bc2

Contents?: true

Size: 1.58 KB

Versions: 129

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

RSpec.describe 'os', :order => :defined do
  def set_stub_chain(keys, value)
      allow(Specinfra).to receive_message_chain([:configuration, keys].flatten).and_return(value)
  end

  describe 'no ssh connection without cache' do
    before do
      property[:os] = nil
      set_stub_chain(:ssh, nil)
      set_stub_chain(:ssh_options, nil)
      set_stub_chain(:host, 'localhost')
      set_stub_chain(:os, :family => 'redhat')
    end

    it { expect(os[:family]).to eq 'redhat' }
  end

  describe 'no ssh connection with cache' do
    it { expect(property[:os]).to eq(:family => 'redhat') }
  end

  describe 'ssh_options without cache' do
    before do
      property[:os] = nil
      set_stub_chain(:ssh, nil)
      set_stub_chain(:ssh_options, :port => 22)
      set_stub_chain(:host, 'localhost')
      set_stub_chain(:os, :family => 'ubuntu')
    end

    it { expect(os[:family]).to eq 'ubuntu' }
  end

  describe 'ssh_options with cache' do
    it { expect(property[:os]).to eq(:family => 'ubuntu') }
  end

  describe 'ssh_connection without cache' do
    before do
      property[:os] = nil
      set_stub_chain([:ssh, :host], 'localhost')
      set_stub_chain([:ssh, :options], :port => 2222)
      set_stub_chain(:os, :family => 'nixos')
    end

    it { expect(os[:family]).to eq 'nixos' }
  end

  describe 'ssh_connection with cache' do
    before do
      set_stub_chain([:ssh, :host], 'localhost')
      set_stub_chain([:ssh, :options], :port => 2222)
      set_stub_chain(:os, :family => 'nixos')
    end

    it { expect(property[:os]).to eq(:family => 'nixos') }
  end
end

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
specinfra-2.76.5 spec/helper/os_spec.rb
specinfra-2.76.4 spec/helper/os_spec.rb
specinfra-2.76.3 spec/helper/os_spec.rb
specinfra-2.76.2 spec/helper/os_spec.rb
specinfra-2.76.1 spec/helper/os_spec.rb
specinfra-2.76.0 spec/helper/os_spec.rb
specinfra-2.75.1 spec/helper/os_spec.rb
specinfra-2.75.0 spec/helper/os_spec.rb
specinfra-2.74.0 spec/helper/os_spec.rb
specinfra-2.73.4 spec/helper/os_spec.rb
specinfra-2.73.3 spec/helper/os_spec.rb
specinfra-2.73.2 spec/helper/os_spec.rb
specinfra-2.73.1 spec/helper/os_spec.rb
specinfra-2.73.0 spec/helper/os_spec.rb
specinfra-2.72.1 spec/helper/os_spec.rb
specinfra-2.72.0 spec/helper/os_spec.rb
specinfra-2.71.3 spec/helper/os_spec.rb
specinfra-2.71.2 spec/helper/os_spec.rb
specinfra-2.71.1 spec/helper/os_spec.rb
specinfra-2.71.0 spec/helper/os_spec.rb