discourse/spec/requests/api/schemas/schema_loader.rb
Blake Erickson c889b676f8
DEV: Updates to api docs schema validation (#11801)
- Read in schemas from actual json files instead of a ruby hash. This is
helpful because we will be automatically generating .json schema files
from json responses and don't want to manually write ruby hash schema
files.

- Create a helper method for rspec schema validation tests to dry up code
2021-01-21 18:23:23 -07:00

19 lines
261 B
Ruby

# frozen_string_literal: true
require 'json'
module SpecSchemas
class SpecLoader
def initialize(filename)
@filename = filename
end
def load
JSON.parse(File.read(File.join(__dir__, "json", "#{@filename}.json")))
end
end
end