Skip to content

Instantly share code, notes, and snippets.

@thedrow
Last active October 6, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedrow/e086203e0768d18e5c92 to your computer and use it in GitHub Desktop.
Save thedrow/e086203e0768d18e5c92 to your computer and use it in GitHub Desktop.
require 'yaml'
module Serverspec
module Type
class YAMLFile < Base
include RSpec::Expectations
def initialize(path)
yaml = YAML.load_file(path)
return unless yaml
yaml.each { |key, value| self.send('#{key}=', value) }
end
def method_missing(m, *args, &block)
# fail here with message
self.fail_with('The key does not exist in the YAML file')
end
end
def yaml_file(path)
YAMLFile.new(path)
end
end
end
include Serverspec::Type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment