class Steep::Expectations
def self.empty
def self.empty new() end
def self.load(path:, content:)
def self.load(path:, content:) expectations = new() YAML.load(content, filename: path.to_s).each do |entry| file = Pathname(entry["file"]) expectations.diagnostics[file] = entry["diagnostics"].map {|hash| Diagnostic.from_hash(hash) }.sort_by!(&:sort_key) end expectations end
def initialize()
def initialize() @diagnostics = {} end
def test(path:, diagnostics:)
def test(path:, diagnostics:) TestResult.new(path: path, expectation: self.diagnostics[path] || [], actual: diagnostics) end
def to_yaml
def to_yaml array = [] #: Array[{ "file" => String, "diagnostics" => Array[untyped] }] diagnostics.each_key.sort.each do |key| ds = diagnostics[key] array << { "file" => key.to_s, 'diagnostics' => ds.sort_by(&:sort_key).map(&:to_hash) } end YAML.dump(array) end