Class: RSpecSystem::Prefab

Inherits:
Object
  • Object
show all
Extended by:
Util
Defined in:
lib/rspec-system/prefab.rb

Overview

This object represents a prefab definition from the prefabs.yml file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

deep_merge!, shellescape

Constructor Details

#initialize(options = {}) ⇒ Prefab

Returns a new instance of Prefab.



31
32
33
34
35
36
# File 'lib/rspec-system/prefab.rb', line 31

def initialize(options = {})
  @name = options[:name]
  @description = options[:description]
  @facts = options[:facts]
  @provider_specifics = options[:provider_specifics]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/rspec-system/prefab.rb', line 7

def description
  @description
end

#factsObject (readonly)

Returns the value of attribute facts.



8
9
10
# File 'lib/rspec-system/prefab.rb', line 8

def facts
  @facts
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rspec-system/prefab.rb', line 6

def name
  @name
end

#provider_specificsObject (readonly)

Returns the value of attribute provider_specifics.



9
10
11
# File 'lib/rspec-system/prefab.rb', line 9

def provider_specifics
  @provider_specifics
end

Class Method Details

.prefab(name, custom_prefabs_path) ⇒ Object

Return prefab object based on name



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rspec-system/prefab.rb', line 12

def self.prefab(name, custom_prefabs_path)
  if File.exists?(custom_prefabs_path)
    custom_prefabs = YAML.load_file(custom_prefabs_path)
  else
    custom_prefabs = {}
  end

  prefabs = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'resources', 'prefabs.yml'))
  deep_merge!(prefabs, custom_prefabs)
  raise "No such prefab" unless pf = prefabs[name]

  RSpecSystem::Prefab.new(
    :name => name,
    :description => pf['description'],
    :facts => pf['facts'],
    :provider_specifics => pf['provider_specifics']
  )
end