Sha256: d358cacde83646c17887057d03a1f28ba4a681acf52066cbd6ebdba66c7556ab
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding : utf-8 -*- require 'pacto' require 'hashie/mash' # Fabricators for Pacto objects representing HTTP transactions Fabricator(:pacto_request, from: Pacto::PactoRequest) do initialize_with { @_klass.new @_transient_attributes } # Hash based initialization # These transient attributes turn into the URI transient host: 'example.com' transient path: '/abcd' transient params: {} method { :get } uri do |attr| Addressable::URI.heuristic_parse(attr[:host]).tap do |uri| uri.path = attr[:path] uri.query_values = attr[:params] end end headers do { 'Server' => ['example.com'], 'Connection' => ['Close'], 'Content-Length' => [1234], 'Via' => ['Some Proxy'], 'User-Agent' => ['rspec'] } end body do |attr| case attr[:method] when :get, :head, :options nil else '{"data": "something"}' end end end Fabricator(:pacto_response, from: Pacto::PactoResponse) do initialize_with { @_klass.new to_hash } # Hash based initialization status { 200 } headers do { 'Content-Type' => 'application/json' } end body { '' } end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | spec/fabricators/http_fabricator.rb |
pacto-0.4.0.rc2 | spec/fabricators/http_fabricator.rb |
pacto-0.4.0.rc1 | spec/fabricators/http_fabricator.rb |