Ravn::SpecHelpers::

WebHelpers module

A collection of test helper functions and classes for web-based systems.

Public Class Methods

included( context )

Inclusion callback – add request builder methods to including contexts.

# File lib/ravn/spec_helpers/web_helpers.rb, line 48
def self::included( context )
        super

        context.include( WebRequestMethods )
end

Public Instance Methods

have_json_body( expected_type=nil )

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/ravn/spec_helpers/web_helpers.rb, line 507
def have_json_body( expected_type=nil )
        return HaveJSONBodyMatcher.new( expected_type )
end
have_json_collection()

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

# File lib/ravn/spec_helpers/web_helpers.rb, line 514
def have_json_collection
        return HaveJSONCollectionMatcher.new
end
last_response_json_body( expected_type=nil )

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

# File lib/ravn/spec_helpers/web_helpers.rb, line 520
def last_response_json_body( expected_type=nil )
        @have_json_body_matcher ||= begin
                matcher = have_json_body( expected_type )
                expect( last_response ).to( matcher )
                matcher
        end

        return @have_json_body_matcher.parsed_response_body
end