module Strelka::Testing

A collection of testing functions and classes for use in Strelka handlers and libraries.

Public Instance Methods

finish_with( status, message=nil, headers={} ) click to toggle source

Match a response thrown via the finish_with function.

# File lib/strelka/testing.rb, line 602
def finish_with( status, message=nil, headers={} )
        return FinishWithMatcher.new( status, message, headers )
end
have_json_body( expected_type=nil ) click to toggle source

Create a new matcher that will expect the response to have a JSON body of the expected_type. If expected_type is omitted, any JSON body will be sufficient for a match.

# File lib/strelka/testing.rb, line 610
def have_json_body( expected_type=nil )
        return HaveJSONBodyMatcher.new( expected_type )
end
have_json_collection() click to toggle source

Create a new matcher that will expect the response to have a JSON body which is an Array of Objects (Hashes).

# File lib/strelka/testing.rb, line 617
def have_json_collection
        return HaveJSONCollectionMatcher.new
end
response_json_body( response ) click to toggle source

Parse the body of the given response and return it as a Ruby object.

# File lib/strelka/testing.rb, line 623
def response_json_body( response )
        response.body.rewind
        Yajl::Parser.parse( response.body, check_utf8: true, symbolize_keys: true )
end