class Pacto::ContractFactory
Attributes
schema[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/pacto/contract_factory.rb, line 5 def initialize(options = {}) @schema = options[:schema] || MetaSchema.new end
Public Instance Methods
build(contract_files, host)
click to toggle source
# File lib/pacto/contract_factory.rb, line 9 def build(contract_files, host) contract_files.map { |file| build_from_file(file, host) } end
build_from_file(contract_path, host)
click to toggle source
# File lib/pacto/contract_factory.rb, line 13 def build_from_file(contract_path, host) contract_definition = File.read(contract_path) definition = JSON.parse(contract_definition) schema.validate definition request = RequestClause.new(host, definition['request']) response = ResponseClause.new(definition['response']) Contract.new(request, response, contract_path, definition['name']) end