Sha256: ba669e1f4de712392d68513d5306eb74c0da79703be0d5e7734128aa528f26cf

Contents?: true

Size: 1.63 KB

Versions: 25

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

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
    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(property[:os_by_host]).to eq nil }
  it { expect(os[:family]).to eq 'redhat' }
end

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

describe 'ssh_options without cache' do
  before do
    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(property[:os_by_host]['localhost:22']).to eq nil }
  it { expect(os[:family]).to eq 'ubuntu' }
end

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

describe 'ssh_connection without 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_by_host]['localhost:2222']).to eq nil }
  it { expect(os[:family]).to eq 'nixos' }
end

describe 'ssh_connection wit 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_by_host]['localhost:2222']).to eq(:family => 'nixos') }
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
specinfra-2.0.0.beta31 spec/helper/os_spec.rb
specinfra-2.0.0.beta30 spec/helper/os_spec.rb
specinfra-2.0.0.beta29 spec/helper/os_spec.rb
specinfra-2.0.0.beta28 spec/helper/os_spec.rb
specinfra-2.0.0.beta27 spec/helper/os_spec.rb
specinfra-2.0.0.beta26 spec/helper/os_spec.rb
specinfra-2.0.0.beta25 spec/helper/os_spec.rb
specinfra-2.0.0.beta24 spec/helper/os_spec.rb
specinfra-2.0.0.beta23 spec/helper/os_spec.rb
specinfra-2.0.0.beta22 spec/helper/os_spec.rb
specinfra-2.0.0.beta21 spec/helper/os_spec.rb
specinfra-2.0.0.beta20 spec/helper/os_spec.rb
specinfra-2.0.0.beta19 spec/helper/os_spec.rb
specinfra-2.0.0.beta18 spec/helper/os_spec.rb
specinfra-2.0.0.beta17 spec/helper/os_spec.rb
specinfra-2.0.0.beta16 spec/helper/os_spec.rb
specinfra-2.0.0.beta15 spec/helper/os_spec.rb
specinfra-2.0.0.beta14 spec/helper/os_spec.rb
specinfra-2.0.0.beta13 spec/helper/os_spec.rb
specinfra-2.0.0.beta12 spec/helper/os_spec.rb