0.0
No commit activity in last 3 years
No release in over 3 years
rack/test based poc file generator, this will make you able to export any data that traveled through the test, and be able to create poc file with that. It is even useful for creating integration test that is based on your api endpoints, because the export file will be serialized into a yaml file that contain all the endpoints that you just tested, and it's inputs and outputs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Rack Test POC

Description

rack/test based poc file generator, this will make you able to export any data that traveled through the test, and be able to create poc file with that. It is even useful for creating integration test that is based on your api endpoints, because the export file will be serialized into a yaml file that contain all the endpoints that you just tested, and it's inputs and outputs

I my self use for documentation and cooperation purpose with other developers

Install

RubyGems/gem command

$ gem install rack-test-poc

Bundler/Gemfile

gem 'rack-test-poc'

Use

All you need to do is to require 'rack/test/poc' in your test_helper when you working with rack-test module, and you good to go!

If you can, you should always describe with :is_for, :it_is_for object methods, the response content, so it can be easy to analyze out from the poc file, or even can be used in documentation generating! With that you can make Google Api docs level documentations!

example

require 'rack'

class APP
  def self.call(env)
    [200, {"Content-Type" => "application/json"}, '{"msg":"Hello Rack!"}']
  end
end

require 'rack/test/poc'
require 'minitest/autorun'

describe 'AppTest' do

  include Rack::Test::Methods

  def app
    APP
  end

  specify 'some rack test!' do

    get '/' #> at this point poc data generated for '/'

    #> bla bla bla some code here
    last_response.body #> '{"msg":"Hello Rack!"}'
    
    #> you should describe a response so it can be easy to understand from the poc!
    resp = JSON.parse(last_response.body)
    resp['msg'].desc 'Hy'
    resp['data']['key'].desc 'bye'

  end


end  
  

this will generate a yaml file with the current unix timestamp in the following format:

---
"/": #> endpoint
  GET: #> endpoint method
    response: 
      body: #> parsed response.body
        msg: Hello Rack!
      status: 200
      format: json #> format of the response
    request:
      query: '' #> query string that been used