Module: GdsApi::TestHelpers::CommonResponses

Included in:
Organisations, Worldwide
Defined in:
lib/gds_api/test_helpers/common_responses.rb

Instance Method Summary collapse

Instance Method Details

#acronymize_slug(slug) ⇒ Object

expects a slug like “ministry-of-funk” returns an acronym like “MOF”



14
15
16
17
# File 'lib/gds_api/test_helpers/common_responses.rb', line 14

def acronymize_slug(slug)
  initials = slug.gsub(/\b\w+/) { |m| m[0] }.delete("-")
  initials.upcase
end

#plural_response_baseObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gds_api/test_helpers/common_responses.rb', line 28

def plural_response_base
  response_base.merge(
    "description" => "Tags!",
    "total" => 100,
    "start_index" => 1,
    "page_size" => 100,
    "current_page" => 1,
    "pages" => 1,
    "results" => [],
  )
end

#response_baseObject Also known as: singular_response_base



19
20
21
22
23
24
25
# File 'lib/gds_api/test_helpers/common_responses.rb', line 19

def response_base
  {
    "_response_info" => {
      "status" => "ok",
    },
  }
end

#titleize_slug(slug, options = {}) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/gds_api/test_helpers/common_responses.rb', line 4

def titleize_slug(slug, options = {})
  if options[:title_case]
    slug.tr("-", " ").gsub(/\b./, &:upcase)
  else
    slug.tr("-", " ").capitalize
  end
end