Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rack-test-poc

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rack-test-poc

  • 3.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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


FAQs

Package last updated on 15 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc