Module: Wrappi::Testing

Defined in:
lib/wrappi/testing.rb

Instance Method Summary collapse

Instance Method Details

#store_response(path, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/wrappi/testing.rb', line 34

def store_response(path, &block)
  endpoint = block.call
  raise "Not succesful call to #{endpoint.class}" unless endpoint.success?
  file_fullname = File.join(path, endpoint.fixture_name)
  return endpoint if File.exists?(file_fullname)
  File.open(file_fullname, "w") do |f|
    f.write(JSON.pretty_generate(endpoint.fixture_content))
  end
  endpoint
end