Class: Faker::Internet::HTTP
- Defined in:
- lib/faker/default/internet_http.rb
Constant Summary collapse
- STATUS_CODES =
{ information: [100, 101, 102, 103], successful: [200, 201, 202, 203, 204, 205, 206, 207, 208, 226], redirect: [300, 301, 302, 303, 304, 305, 306, 307, 308], client_error: [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451], server_error: [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511] }.freeze
- STATUS_CODES_GROUPS =
STATUS_CODES.keys.freeze
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.status_code(group: nil) ⇒ Integer
Produces an HTTP status code.
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.status_code(group: nil) ⇒ Integer
Produces an HTTP status code
38 39 40 41 42 43 44 |
# File 'lib/faker/default/internet_http.rb', line 38 def status_code(group: nil) return STATUS_CODES[STATUS_CODES_GROUPS.sample].sample unless group raise ArgumentError, 'Invalid HTTP status code group' unless STATUS_CODES_GROUPS.include?(group) STATUS_CODES[group].sample end |