Sha256: 15421d09841b974850f9ba0f6618b18cd948b8773f00afd532d9d03ddce03ec5

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

module RSpecSystem
  # This object represents a prefab definition from the prefabs.yml file
  class Prefab
    extend RSpecSystem::Util

    attr_reader :name
    attr_reader :description
    attr_reader :facts
    attr_reader :provider_specifics

    # Return prefab object based on name
    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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rspec-system-2.8.0 lib/rspec-system/prefab.rb
rspec-system-2.7.2 lib/rspec-system/prefab.rb
rspec-system-2.7.1 lib/rspec-system/prefab.rb
rspec-system-2.7.0 lib/rspec-system/prefab.rb
rspec-system-2.6.0 lib/rspec-system/prefab.rb
rspec-system-2.5.1 lib/rspec-system/prefab.rb
rspec-system-2.5.0 lib/rspec-system/prefab.rb
rspec-system-2.4.0 lib/rspec-system/prefab.rb
rspec-system-2.3.0 lib/rspec-system/prefab.rb
rspec-system-2.2.1 lib/rspec-system/prefab.rb
rspec-system-2.2.0 lib/rspec-system/prefab.rb
rspec-system-2.1.2 lib/rspec-system/prefab.rb
rspec-system-2.1.1 lib/rspec-system/prefab.rb
rspec-system-2.1.0 lib/rspec-system/prefab.rb