Module: BeyondTheApiTestHelpers::Request::IndexAssertions

Defined in:
lib/beyond_the_api_test_helpers/request/index_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_request_index_not_found(urls_not_found, options = {}) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/beyond_the_api_test_helpers/request/index_assertions.rb', line 43

def assert_request_index_not_found(urls_not_found, options = {})
  request_instance_variables_set options
  @headers.merge!(logged_in_headers) if 

  urls_not_found.each do |url_not_found|
    assert_request_index_not_found_i18n_all(url_not_found)
  end
end

#assert_request_index_paginated(url, params = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/beyond_the_api_test_helpers/request/index_assertions.rb', line 25

def assert_request_index_paginated(url, params = {})
  request_instance_variables_set_pluralize params
  @headers.merge!(logged_in_headers) if 

  get(url, params: @params.merge(page: 1, per_page: 1, total_pages: true), headers: @headers)
  assert_equal 1, json_response_name.size
  assert_kind_of Integer, meta['total_pages']
end

#assert_request_index_total_count(url, options = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/beyond_the_api_test_helpers/request/index_assertions.rb', line 18

def assert_request_index_total_count(url, options = {})
  request_instance_variables_set_pluralize options
  @headers.merge!(logged_in_headers) if 
  get(url, params: @params.merge(total_count: true), headers: @headers)
  assert_kind_of Integer, meta['total_count']
end

#assert_request_index_valid(url, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/beyond_the_api_test_helpers/request/index_assertions.rb', line 4

def assert_request_index_valid(url, options = {})
  request_instance_variables_set_pluralize options

  if 
    assert_request_needs_to_be_logged(url, :get)
    @headers.merge!(logged_in_headers)
  end

  get(url, params: @params, headers: @headers)
  response_assertions(status: 200)
  assert_kind_of Array, json_response_name
  assert_request_index_should_include if @should_include || @should_not_include
end

#assert_request_index_with_filters(url, filters, params = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/beyond_the_api_test_helpers/request/index_assertions.rb', line 34

def assert_request_index_with_filters(url, filters, params = {})
  request_instance_variables_set_pluralize params
  @headers.merge!(logged_in_headers) if 

  filters.each do |key, options|
    assert_request_index_filter(url, key, options)
  end
end