mockeroo-mock-responses 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +50 -0
- data/lib/mockeroo_mock_responses/version.rb +5 -0
- data/lib/mockeroo_mock_responses.rb +58 -0
- data/responses/200.json +12 -0
- data/responses/201.json +7 -0
- data/responses/204.json +7 -0
- data/responses/301.json +7 -0
- data/responses/302.json +7 -0
- data/responses/304.json +7 -0
- data/responses/400.json +12 -0
- data/responses/401.json +10 -0
- data/responses/403.json +10 -0
- data/responses/404.json +12 -0
- data/responses/405.json +7 -0
- data/responses/408.json +7 -0
- data/responses/409.json +7 -0
- data/responses/413.json +7 -0
- data/responses/418.json +7 -0
- data/responses/429.json +12 -0
- data/responses/500.json +12 -0
- data/responses/502.json +7 -0
- data/responses/503.json +7 -0
- data/responses/504.json +7 -0
- metadata +66 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 68742c88160e76ebccd00a5ef6bcf74fc7ea625d755a3a379e8fae0c765d0e79
|
|
4
|
+
data.tar.gz: fe08f588f5e213b864d25cd249eb2c82b3fe52d4656e8c9db01e1440149935dd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a6c8c98a659982ef60534f5dde99e0a98942647e21acb7768a408a7a22af096f8abcf815d3ce2c8cad135d3235b62080a8de050b8543ecd8fccdcbd8d6d7067f
|
|
7
|
+
data.tar.gz: 07dbbd1a42574cbcae3229cca2c51209925b3523b2e788ed0d3a72be0b51ea4283b8e325f2f4067bce93aa8164bf45afe19cca067493f4ad3fe9615129c7eb25
|
data/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# mockeroo-mock-responses (Ruby)
|
|
2
|
+
|
|
3
|
+
Sarcastic HTTP status code responses for testing and development.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
require 'mockeroo_mock_responses'
|
|
7
|
+
|
|
8
|
+
resp = MockerooMockResponses.get_response(404)
|
|
9
|
+
puts "#{resp.status}: #{resp.message}"
|
|
10
|
+
# => 404: Whatever you're looking for, it's not here. Just like my will to help you.
|
|
11
|
+
|
|
12
|
+
codes = MockerooMockResponses.get_available_codes
|
|
13
|
+
puts codes.inspect
|
|
14
|
+
# => [200, 201, 204, 301, 302, 304, 400, 401, 403, 404, 405, 408, 409, 413, 418, 429, 500, 502, 503, 504]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
gem install mockeroo-mock-responses
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or add to your Gemfile:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'mockeroo-mock-responses'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
### `MockerooMockResponses.get_response(status_code) -> Response | nil`
|
|
32
|
+
|
|
33
|
+
Returns a `Response` struct with `.status` (Integer) and `.message` (String), or `nil`
|
|
34
|
+
if the status code is not recognised. Each call picks a random message from the pool.
|
|
35
|
+
|
|
36
|
+
### `MockerooMockResponses.get_available_codes -> Array<Integer>`
|
|
37
|
+
|
|
38
|
+
Returns all supported HTTP status codes in ascending order. Each call returns a new
|
|
39
|
+
array; mutating it has no effect on the library state.
|
|
40
|
+
|
|
41
|
+
## Running tests
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd ruby
|
|
45
|
+
ruby test/test_mockeroo_mock_responses.rb
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
# Sarcastic HTTP status code responses for testing and development.
|
|
6
|
+
#
|
|
7
|
+
# Mirrors the behaviour of the @mockeroo/mock-responses npm package.
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
#
|
|
11
|
+
# require 'mockeroo_mock_responses'
|
|
12
|
+
#
|
|
13
|
+
# resp = MockerooMockResponses.get_response(404)
|
|
14
|
+
# puts "#{resp.status}: #{resp.message}" if resp
|
|
15
|
+
#
|
|
16
|
+
# codes = MockerooMockResponses.get_available_codes
|
|
17
|
+
# puts codes.inspect # [200, 201, 204, ...]
|
|
18
|
+
#
|
|
19
|
+
# Response data is loaded from the canonical responses/*.json files at require time.
|
|
20
|
+
module MockerooMockResponses
|
|
21
|
+
# A response holding an HTTP status code and a randomly chosen sarcastic message.
|
|
22
|
+
Response = Struct.new(:status, :message)
|
|
23
|
+
|
|
24
|
+
# Load responses from the canonical ../responses/*.json files.
|
|
25
|
+
# Falls back to a bundled `responses/` directory if present (for gem installs).
|
|
26
|
+
def self._load_responses
|
|
27
|
+
bundled = File.expand_path('../../responses', __dir__)
|
|
28
|
+
monorepo = File.expand_path('../../../responses', __dir__)
|
|
29
|
+
dir = File.exist?(bundled) ? bundled : monorepo
|
|
30
|
+
|
|
31
|
+
data = {}
|
|
32
|
+
Dir.glob(File.join(dir, '*.json')).each do |file|
|
|
33
|
+
code = Integer(File.basename(file, '.json'))
|
|
34
|
+
messages = JSON.parse(File.read(file, encoding: 'utf-8'))
|
|
35
|
+
data[code] = messages unless messages.empty?
|
|
36
|
+
end
|
|
37
|
+
data
|
|
38
|
+
end
|
|
39
|
+
private_class_method :_load_responses
|
|
40
|
+
|
|
41
|
+
RESPONSES = _load_responses.freeze
|
|
42
|
+
CODES = RESPONSES.keys.sort.freeze
|
|
43
|
+
|
|
44
|
+
# Returns a Response with a random sarcastic message for the given HTTP
|
|
45
|
+
# status code, or nil if the code is not recognised.
|
|
46
|
+
def self.get_response(status_code)
|
|
47
|
+
messages = RESPONSES[status_code.to_i]
|
|
48
|
+
return nil unless messages
|
|
49
|
+
|
|
50
|
+
Response.new(status_code.to_i, messages.sample)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns all supported HTTP status codes in ascending order.
|
|
54
|
+
# Each call returns a new array so callers may modify it freely.
|
|
55
|
+
def self.get_available_codes
|
|
56
|
+
CODES.dup
|
|
57
|
+
end
|
|
58
|
+
end
|
data/responses/200.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Okay, what you gonna do next, son?",
|
|
3
|
+
"Congrats, you managed to not break anything. For once.",
|
|
4
|
+
"Wow, it actually worked. I'm as surprised as you are.",
|
|
5
|
+
"Success! But let's not get cocky about it.",
|
|
6
|
+
"Here's your data. You're welcome, I guess.",
|
|
7
|
+
"Everything's fine. No thanks to you.",
|
|
8
|
+
"Look at you, making successful requests like a big kid.",
|
|
9
|
+
"200 OK. Don't let it go to your head.",
|
|
10
|
+
"It worked. Try not to act so surprised.",
|
|
11
|
+
"Sure, here you go. Not like I had anything better to do."
|
|
12
|
+
]
|
data/responses/201.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Oh great, you made something. The world definitely needed more of whatever this is.",
|
|
3
|
+
"Created! Another thing for me to keep track of. Thanks.",
|
|
4
|
+
"Fine, I made your little resource. Happy now?",
|
|
5
|
+
"Congratulations, it's a resource! 8 pounds, 3 ounces.",
|
|
6
|
+
"Created successfully. I'll add it to the pile."
|
|
7
|
+
]
|
data/responses/204.json
ADDED
data/responses/301.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"We moved. Didn't feel like telling you. New address over there.",
|
|
3
|
+
"This resource packed its bags and left. Permanently. Can you blame it?",
|
|
4
|
+
"Forwarding address left at the desk. Try to keep up.",
|
|
5
|
+
"Gone. Moved on. Like you should.",
|
|
6
|
+
"We've relocated. Update your bookmarks, grandpa."
|
|
7
|
+
]
|
data/responses/302.json
ADDED
data/responses/304.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Nothing changed since you last checked. Quit being so clingy.",
|
|
3
|
+
"Still the same. You can stop refreshing now.",
|
|
4
|
+
"I literally just told you this. Use your cache.",
|
|
5
|
+
"Didn't change. Shocking, I know.",
|
|
6
|
+
"Same as before. What part of 'not modified' don't you understand?"
|
|
7
|
+
]
|
data/responses/400.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Can you at least give me something proper to work with??",
|
|
3
|
+
"I've seen better requests from a broken keyboard.",
|
|
4
|
+
"What even is this request? Did you write it with your elbows?",
|
|
5
|
+
"Bad request. Bad! Go sit in the corner and think about what you sent me.",
|
|
6
|
+
"I tried to understand your request. I really did. I failed.",
|
|
7
|
+
"This request is so bad it made my parser cry.",
|
|
8
|
+
"Error 400: You had ONE job.",
|
|
9
|
+
"I'm not mad, I'm just disappointed in your request.",
|
|
10
|
+
"My toddler could craft a better request than this.",
|
|
11
|
+
"Have you considered reading the documentation? Just a thought."
|
|
12
|
+
]
|
data/responses/401.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Who are you? No really, WHO ARE YOU?",
|
|
3
|
+
"Nice try, stranger. Show me some ID.",
|
|
4
|
+
"Authentication required. And no, 'please' is not a valid token.",
|
|
5
|
+
"You shall not pass! ...without proper credentials.",
|
|
6
|
+
"Sorry, I don't talk to strangers. Authenticate first.",
|
|
7
|
+
"Access denied. Did you forget your password again?",
|
|
8
|
+
"Unauthorized. Much like your opinions.",
|
|
9
|
+
"I don't know you. I don't want to know you. Authenticate."
|
|
10
|
+
]
|
data/responses/403.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[
|
|
2
|
+
"You can't sit with us.",
|
|
3
|
+
"Forbidden. And no amount of begging will change that.",
|
|
4
|
+
"I know who you are. You still can't come in.",
|
|
5
|
+
"Permission denied. This is above your pay grade.",
|
|
6
|
+
"Nope. Not happening. Don't even ask.",
|
|
7
|
+
"Forbidden. It's not you, it's... no wait, it IS you.",
|
|
8
|
+
"You have no power here.",
|
|
9
|
+
"Nice credentials. Still no."
|
|
10
|
+
]
|
data/responses/404.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Whatever you're looking for, it's not here. Just like my will to help you.",
|
|
3
|
+
"404: Your request, much like your social life, could not be found.",
|
|
4
|
+
"It's gone. Poof. Maybe it never existed. Like your debugging skills.",
|
|
5
|
+
"Not found. Have you tried looking under the couch cushions?",
|
|
6
|
+
"The resource you requested has left the chat.",
|
|
7
|
+
"Looked everywhere. Under the server rack, behind the firewall. Nope.",
|
|
8
|
+
"This page is playing hide and seek. It's winning.",
|
|
9
|
+
"404: Page not found. But you know what else isn't found? My patience.",
|
|
10
|
+
"Gone. Vanished. Disappeared. Much like my motivation.",
|
|
11
|
+
"If this resource was a person, it'd be in witness protection."
|
|
12
|
+
]
|
data/responses/405.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"You can't do that here. Wrong method, wrong place, wrong time.",
|
|
3
|
+
"That method isn't allowed. Try something else. Or don't. I don't care.",
|
|
4
|
+
"Did you really just try that? With THAT method?",
|
|
5
|
+
"Method not allowed. It's not a suggestion, it's a rule.",
|
|
6
|
+
"Wrong verb. This endpoint doesn't respond to whatever that was."
|
|
7
|
+
]
|
data/responses/408.json
ADDED
data/responses/409.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Conflict! Now there are two of them. This is getting out of hand.",
|
|
3
|
+
"You're trying to do something that contradicts something else. Classic you.",
|
|
4
|
+
"Conflict detected. Just like every meeting you're in.",
|
|
5
|
+
"The resource is in a state that conflicts with your request. Join the club.",
|
|
6
|
+
"You and the server have different ideas about reality. The server wins."
|
|
7
|
+
]
|
data/responses/413.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Whoa whoa whoa. That payload is WAY too big. What are you sending, a novel?",
|
|
3
|
+
"Your request is too thicc. Put it on a diet.",
|
|
4
|
+
"Payload too large. This isn't a storage unit.",
|
|
5
|
+
"I can't handle all of... THAT. Trim it down.",
|
|
6
|
+
"Too much data. I'm a server, not a warehouse."
|
|
7
|
+
]
|
data/responses/418.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"I'm a teapot. Short and stout. Here is my handle, here is my spout.",
|
|
3
|
+
"I refuse to brew coffee. I'm a teapot. Read the RFC.",
|
|
4
|
+
"418: Still a teapot. Still not making coffee. Deal with it.",
|
|
5
|
+
"Teapot status: still a teapot. Coffee status: still not happening.",
|
|
6
|
+
"I identify as a teapot and I'm not about to change for you."
|
|
7
|
+
]
|
data/responses/429.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Stop harassing me, give me some space will ya?",
|
|
3
|
+
"Too many requests! What am I, your therapist?",
|
|
4
|
+
"Slow. Down. I can only handle so much of you.",
|
|
5
|
+
"Rate limited. Take a walk. Touch some grass.",
|
|
6
|
+
"You again?! I JUST saw you! Give it a rest!",
|
|
7
|
+
"Calm down. The server needs personal space too.",
|
|
8
|
+
"Too many requests. You're not my only client, you know.",
|
|
9
|
+
"Whoa there, eager beaver. Back off a little.",
|
|
10
|
+
"I'm going to need you to take several seats.",
|
|
11
|
+
"Rate limit exceeded. I'm putting you in timeout."
|
|
12
|
+
]
|
data/responses/500.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Don't feel like responding right now.",
|
|
3
|
+
"Something broke. It was probably your fault, but I'll take the blame.",
|
|
4
|
+
"Internal Server Error. Translation: I have no idea what just happened.",
|
|
5
|
+
"Oopsie. Something went boom on my end.",
|
|
6
|
+
"The server is having an existential crisis. Please hold.",
|
|
7
|
+
"Everything is on fire but it's fine. This is fine.",
|
|
8
|
+
"500: I broke. You broke me. I hope you're happy.",
|
|
9
|
+
"Internal error. The hamster powering the server fell off the wheel.",
|
|
10
|
+
"My bad. But also, somehow, your bad too.",
|
|
11
|
+
"Server error. Have you tried turning me off and on again?"
|
|
12
|
+
]
|
data/responses/502.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"The server behind me is being difficult. I relate.",
|
|
3
|
+
"Bad gateway. The upstream server is ghosting me.",
|
|
4
|
+
"I asked the other server for help. It said no.",
|
|
5
|
+
"502: Even servers have trust issues.",
|
|
6
|
+
"The backend just gave me nonsense. I can't work with this."
|
|
7
|
+
]
|
data/responses/503.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Service unavailable. I'm on break. Check back never.",
|
|
3
|
+
"The server is taking a mental health day.",
|
|
4
|
+
"Currently unavailable. Try again later. Or don't. I'm not your mom.",
|
|
5
|
+
"Out of service. Like your code after Friday deploys.",
|
|
6
|
+
"I'm overloaded. Just like your mom's spaghetti. Wait, that's not right."
|
|
7
|
+
]
|
data/responses/504.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Gateway timeout. The upstream server left me on read.",
|
|
3
|
+
"Waited for a response from the other server. Still waiting. Always waiting.",
|
|
4
|
+
"Timed out waiting for backup. Story of my life.",
|
|
5
|
+
"The upstream server is taking forever. Must be running JavaScript.",
|
|
6
|
+
"504: I asked for help and got ghosted. Classic."
|
|
7
|
+
]
|
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mockeroo-mock-responses
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- mockeroo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Like Mockoon, but worse. Returns sarcastic mock HTTP responses.
|
|
14
|
+
email:
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- lib/mockeroo_mock_responses.rb
|
|
21
|
+
- lib/mockeroo_mock_responses/version.rb
|
|
22
|
+
- responses/200.json
|
|
23
|
+
- responses/201.json
|
|
24
|
+
- responses/204.json
|
|
25
|
+
- responses/301.json
|
|
26
|
+
- responses/302.json
|
|
27
|
+
- responses/304.json
|
|
28
|
+
- responses/400.json
|
|
29
|
+
- responses/401.json
|
|
30
|
+
- responses/403.json
|
|
31
|
+
- responses/404.json
|
|
32
|
+
- responses/405.json
|
|
33
|
+
- responses/408.json
|
|
34
|
+
- responses/409.json
|
|
35
|
+
- responses/413.json
|
|
36
|
+
- responses/418.json
|
|
37
|
+
- responses/429.json
|
|
38
|
+
- responses/500.json
|
|
39
|
+
- responses/502.json
|
|
40
|
+
- responses/503.json
|
|
41
|
+
- responses/504.json
|
|
42
|
+
homepage: https://github.com/mockeroo/mock-responses
|
|
43
|
+
licenses:
|
|
44
|
+
- MIT
|
|
45
|
+
metadata:
|
|
46
|
+
source_code_uri: https://github.com/mockeroo/mock-responses
|
|
47
|
+
post_install_message:
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '2.7'
|
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
requirements: []
|
|
62
|
+
rubygems_version: 3.5.22
|
|
63
|
+
signing_key:
|
|
64
|
+
specification_version: 4
|
|
65
|
+
summary: Sarcastic HTTP status code responses for testing and development.
|
|
66
|
+
test_files: []
|