lib/pacto/contract.rb in pacto-0.4.0.rc1 vs lib/pacto/contract.rb in pacto-0.4.0.rc2
- old
+ new
@@ -1,31 +1,30 @@
# -*- encoding : utf-8 -*-
module Pacto
- class Contract < Pacto::Dash
- property :id
- property :file
- property :request, required: true
- # Although I'd like response to be required, it complicates
- # the partial contracts used the rake generation task...
- # yet another reason I'd like to deprecate that feature
- property :response # , required: true
- property :values, default: {}
- # Gotta figure out how to use test doubles w/ coercion
- coerce_key :request, RequestClause
- coerce_key :response, ResponseClause
- property :examples
- property :name, required: true
- property :adapter, default: proc { Pacto.configuration.adapter }
- property :consumer, default: proc { Pacto.configuration.default_consumer }
- property :provider, default: proc { Pacto.configuration.default_provider }
+ module Contract
+ include Logger
- def initialize(opts)
- if opts[:file]
- opts[:file] = Addressable::URI.convert_path(File.expand_path(opts[:file])).to_s
- opts[:name] ||= opts[:file]
- end
- opts[:id] ||= (opts[:summary] || opts[:file])
- super
+ attr_reader :id
+ attr_reader :file
+ attr_reader :request
+ attr_reader :response
+ attr_reader :values
+ attr_reader :examples
+ attr_reader :name
+ attr_writer :adapter
+ attr_writer :consumer
+ attr_writer :provider
+
+ def adapter
+ @adapter ||= Pacto.configuration.adapter
+ end
+
+ def consumer
+ @consumer ||= Pacto.configuration.default_consumer
+ end
+
+ def provider
+ @provider ||= Pacto.configuration.default_provider
end
def examples?
examples && !examples.empty?
end