Module: APIMatchers::RSpecMatchers

Defined in:
lib/api_matchers/core/rspec_matchers.rb

Instance Method Summary collapse

Instance Method Details

#be_bad_requestObject Also known as: be_a_bad_request



3
4
5
# File 'lib/api_matchers/core/rspec_matchers.rb', line 3

def be_bad_request
  ::APIMatchers::HTTPStatusCode::BeBadRequest.new(::APIMatchers::Core::Setup)
end

#be_internal_server_errorObject Also known as: be_an_internal_server_error



12
13
14
# File 'lib/api_matchers/core/rspec_matchers.rb', line 12

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

#be_jsonObject Also known as: be_in_json, be_a_json



39
40
41
# File 'lib/api_matchers/core/rspec_matchers.rb', line 39

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

#be_not_foundObject



8
9
10
# File 'lib/api_matchers/core/rspec_matchers.rb', line 8

def be_not_found
  ::APIMatchers::HTTPStatusCode::BeNotFound.new(::APIMatchers::Core::Setup)
end

#be_okObject



21
22
23
# File 'lib/api_matchers/core/rspec_matchers.rb', line 21

def be_ok
  ::APIMatchers::HTTPStatusCode::BeOk.new(::APIMatchers::Core::Setup)
end

#be_unauthorizedObject



17
18
19
# File 'lib/api_matchers/core/rspec_matchers.rb', line 17

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

#be_unprocessable_entityObject



25
26
27
# File 'lib/api_matchers/core/rspec_matchers.rb', line 25

def be_unprocessable_entity
  ::APIMatchers::HTTPStatusCode::BeUnprocessableEntity.new(::APIMatchers::Core::Setup)
end

#be_xmlObject Also known as: be_in_xml



34
35
36
# File 'lib/api_matchers/core/rspec_matchers.rb', line 34

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

#create_resourceObject Also known as: created_resource



29
30
31
# File 'lib/api_matchers/core/rspec_matchers.rb', line 29

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

#have_json(expected_json) ⇒ Object



53
54
55
# File 'lib/api_matchers/core/rspec_matchers.rb', line 53

def have_json(expected_json)
  ::APIMatchers::ResponseBody::HaveJson.new(expected_json)
end

#have_json_node(expected_node) ⇒ Object



45
46
47
# File 'lib/api_matchers/core/rspec_matchers.rb', line 45

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

#have_node(expected_node) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/api_matchers/core/rspec_matchers.rb', line 57

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

#have_xml_node(expected_node) ⇒ Object



49
50
51
# File 'lib/api_matchers/core/rspec_matchers.rb', line 49

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