Sha256: 2de4f326eeed7b7c9be8ba25cde37376ccc27a02c50963173c5f4be830104494

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

module MockCollinsMixin
  require 'collins_client'

  def test_assets
    Dir.glob('spec/fixtures/assets/*.yml').map do |f|
      YAML.load(File.read(f))
    end
  end

  def get_test_asset tag
    test_assets.select { |a| a.tag == tag }
  end

  def mock_collins
    allow_any_instance_of(Collins::Client).to receive(:find).
                                               with(Hash).
                                               and_return([])

    allow_any_instance_of(Collins::Client).to receive(:find).
                                              with(hash_including(:hostname => 'hostname-with-multiple-assets.dc.net')).
                                              and_return(['asset1', 'asset2'])


    ['safe-allocated-tag', 'safe-maintenance-tag', 'dangerous-allocated-tag', 'dangerous-maintenance-tag'].each do |tag|
      allow_any_instance_of(Collins::Client).to receive(:find).
                                                 with(hash_including(:tag => tag)).
                                                 and_return(get_test_asset(tag))
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
consolr-1.1.5 spec/mocks/collins.rb
consolr-1.1.4 spec/mocks/collins.rb
consolr-1.1.1 spec/mocks/collins.rb
consolr-1.1.0 spec/mocks/collins.rb
consolr-1.1.3 spec/mocks/collins.rb
consolr-1.1.2 spec/mocks/collins.rb
consolr-1.0.2 spec/mocks/collins.rb