Sha256: e6eeecf0277c982e1626ab1c02df36d376638c30f854bf5d0cba0ba95593b9d2

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module APIMatchers
  module RSpecMatchers
    def be_bad_request
      ::APIMatchers::HTTPStatusCode::BeBadRequest.new(::APIMatchers::Core::Setup)
    end
    alias :be_a_bad_request :be_bad_request

    def be_internal_server_error
      ::APIMatchers::HTTPStatusCode::BeInternalServerError.new(::APIMatchers::Core::Setup)
    end
    alias :be_an_internal_server_error :be_internal_server_error

    def be_unauthorized
      ::APIMatchers::HTTPStatusCode::BeUnauthorized.new(::APIMatchers::Core::Setup)
    end

    def create_resource
      ::APIMatchers::HTTPStatusCode::CreateResource.new(::APIMatchers::Core::Setup)
    end
    alias :created_resource :create_resource

    def be_xml
      ::APIMatchers::Headers::BeXML.new(::APIMatchers::Core::Setup)
    end
    alias :be_in_xml :be_xml

    def be_json
      ::APIMatchers::Headers::BeJSON.new(::APIMatchers::Core::Setup)
    end
    alias :be_in_json :be_json
    alias :be_a_json  :be_json

    def have_json_node(expected_node)
      ::APIMatchers::ResponseBody::HaveJsonNode.new(expected_node: expected_node, setup: ::APIMatchers::Core::Setup)
    end

    def have_xml_node(expected_node)
      ::APIMatchers::ResponseBody::HaveXmlNode.new(expected_node: expected_node, setup: ::APIMatchers::Core::Setup)
    end

    def have_node(expected_node)
      if ::APIMatchers::Core::Setup.have_node_matcher.equal?(:json)
        have_json_node(expected_node)
      else
        have_xml_node(expected_node)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_matchers-0.1.1 lib/api_matchers/core/rspec_matchers.rb
api_matchers-0.1.0 lib/api_matchers/core/rspec_matchers.rb
api_matchers-0.0.2 lib/api_matchers/core/rspec_matchers.rb
api_matchers-0.0.1 lib/api_matchers/core/rspec_matchers.rb