Sha256: 7c5d0dc2e33b2c0120a0b3d3091d9d23e389f41f93e27ef4248f1d35c1550479

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

require 'map'

module ApiPi
  class Dsl

    attr_reader :response, :tests

    def initialize response
      @tests = {}
      @response = Map.new(response)
    end

    def parse url, block
      self.instance_eval(&block)
      pi = ApiPi::Case.new(url, tests)
      pi.investigate
    end

    # Test blocks are used to group similar assertions into readable units.  
    # 
    # For example, you may want to put your header tests into one test block:
    # 
    #     get 'example.com/user.json' do
    #       test 'Headers have correct data' do
    #         # You header assertions...
    #       end
    #     end
    # 
    # Inside of the test block, you would then put your header assertions.
    # onceyou run your tests, your test blocks are grouped together and 
    # pass/fail based on  assertions in the test block.

    def test desc, &block
      @tests[desc] = block
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
api_pi-0.9 lib/api_pi/dsl.rb
api_pi-0.2.3 lib/api_pi/dsl.rb
api_pi-0.2.2 lib/api_pi/dsl.rb