Last active
October 6, 2015 14:49
-
-
Save thedrow/e086203e0768d18e5c92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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