reqcord 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile +5 -0
- data/README.md +13 -0
- data/gemfiles/rails_7.1.gemfile +13 -0
- data/gemfiles/rails_7.2.gemfile +13 -0
- data/gemfiles/rails_8.0.gemfile +13 -0
- data/gemfiles/rails_8.1.gemfile +13 -0
- data/lib/reqcord/version.rb +1 -1
- data/reqcord.gemspec +18 -4
- metadata +65 -217
- data/.gitignore +0 -8
- data/Gemfile.lock +0 -171
- data/examples/complex-spec-app/.rspec +0 -1
- data/examples/complex-spec-app/README.md +0 -21
- data/examples/complex-spec-app/app.rb +0 -363
- data/examples/complex-spec-app/docs/api/README.md +0 -104
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/create.md +0 -117
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/destroy.md +0 -51
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/index.md +0 -11
- data/examples/complex-spec-app/docs/api/api/v1/admin/products/list.md +0 -106
- data/examples/complex-spec-app/docs/api/api/v1/auth/index.md +0 -9
- data/examples/complex-spec-app/docs/api/api/v1/auth/login.md +0 -76
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/create.md +0 -91
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/destroy.md +0 -51
- data/examples/complex-spec-app/docs/api/api/v1/cart-items/index.md +0 -10
- data/examples/complex-spec-app/docs/api/api/v1/carts/checkout.md +0 -102
- data/examples/complex-spec-app/docs/api/api/v1/carts/index.md +0 -10
- data/examples/complex-spec-app/docs/api/api/v1/carts/show.md +0 -73
- data/examples/complex-spec-app/docs/api/api/v1/home/index.md +0 -9
- data/examples/complex-spec-app/docs/api/api/v1/home/list.md +0 -47
- data/examples/complex-spec-app/docs/api/api/v1/notes/create.md +0 -94
- data/examples/complex-spec-app/docs/api/api/v1/notes/index.md +0 -10
- data/examples/complex-spec-app/docs/api/api/v1/notes/list.md +0 -61
- data/examples/complex-spec-app/docs/api/api/v1/orders/cancel.md +0 -69
- data/examples/complex-spec-app/docs/api/api/v1/orders/create.md +0 -150
- data/examples/complex-spec-app/docs/api/api/v1/orders/destroy.md +0 -37
- data/examples/complex-spec-app/docs/api/api/v1/orders/index.md +0 -13
- data/examples/complex-spec-app/docs/api/api/v1/orders/list.md +0 -78
- data/examples/complex-spec-app/docs/api/api/v1/orders/show.md +0 -83
- data/examples/complex-spec-app/docs/api/api/v1/products/index.md +0 -11
- data/examples/complex-spec-app/docs/api/api/v1/products/list.md +0 -83
- data/examples/complex-spec-app/docs/api/api/v1/products/search.md +0 -88
- data/examples/complex-spec-app/docs/api/api/v1/products/show.md +0 -71
- data/examples/complex-spec-app/docs/api/api/v1/profiles/index.md +0 -10
- data/examples/complex-spec-app/docs/api/api/v1/profiles/show.md +0 -61
- data/examples/complex-spec-app/docs/api/api/v1/profiles/update.md +0 -91
- data/examples/complex-spec-app/docs/api/api/v2/products/index.md +0 -9
- data/examples/complex-spec-app/docs/api/api/v2/products/list.md +0 -77
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/create.sh +0 -18
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/destroy.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/admin/products/list.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/auth/login.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/cart-items/create.sh +0 -16
- data/examples/complex-spec-app/docs/api/curl/api/v1/cart-items/destroy.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/carts/checkout.sh +0 -13
- data/examples/complex-spec-app/docs/api/curl/api/v1/carts/show.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/home/list.sh +0 -8
- data/examples/complex-spec-app/docs/api/curl/api/v1/notes/create.sh +0 -15
- data/examples/complex-spec-app/docs/api/curl/api/v1/notes/list.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/cancel.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/create.sh +0 -29
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/destroy.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/list.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/orders/show.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/list.sh +0 -8
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/search.sh +0 -8
- data/examples/complex-spec-app/docs/api/curl/api/v1/products/show.sh +0 -8
- data/examples/complex-spec-app/docs/api/curl/api/v1/profiles/show.sh +0 -9
- data/examples/complex-spec-app/docs/api/curl/api/v1/profiles/update.sh +0 -16
- data/examples/complex-spec-app/docs/api/curl/api/v2/products/list.sh +0 -8
- data/examples/complex-spec-app/docs/api/dataset.json +0 -5116
- data/examples/complex-spec-app/docs/api/postman/collection.json +0 -2519
- data/examples/complex-spec-app/generate.rb +0 -14
- data/examples/complex-spec-app/reqcord.yml +0 -28
- data/examples/complex-spec-app/spec/requests/admin_spec.rb +0 -67
- data/examples/complex-spec-app/spec/requests/cart_spec.rb +0 -61
- data/examples/complex-spec-app/spec/requests/home_and_auth_spec.rb +0 -49
- data/examples/complex-spec-app/spec/requests/orders_spec.rb +0 -124
- data/examples/complex-spec-app/spec/requests/products_spec.rb +0 -65
- data/examples/complex-spec-app/spec/spec_helper.rb +0 -17
- data/examples/complex-test-app/README.md +0 -40
- data/examples/complex-test-app/app.rb +0 -384
- data/examples/complex-test-app/docs/api/README.md +0 -104
- data/examples/complex-test-app/docs/api/api/v1/admin/products/create.md +0 -117
- data/examples/complex-test-app/docs/api/api/v1/admin/products/destroy.md +0 -51
- data/examples/complex-test-app/docs/api/api/v1/admin/products/index.md +0 -11
- data/examples/complex-test-app/docs/api/api/v1/admin/products/list.md +0 -106
- data/examples/complex-test-app/docs/api/api/v1/auth/index.md +0 -9
- data/examples/complex-test-app/docs/api/api/v1/auth/login.md +0 -76
- data/examples/complex-test-app/docs/api/api/v1/cart-items/create.md +0 -91
- data/examples/complex-test-app/docs/api/api/v1/cart-items/destroy.md +0 -51
- data/examples/complex-test-app/docs/api/api/v1/cart-items/index.md +0 -10
- data/examples/complex-test-app/docs/api/api/v1/carts/checkout.md +0 -102
- data/examples/complex-test-app/docs/api/api/v1/carts/index.md +0 -10
- data/examples/complex-test-app/docs/api/api/v1/carts/show.md +0 -73
- data/examples/complex-test-app/docs/api/api/v1/home/index.md +0 -9
- data/examples/complex-test-app/docs/api/api/v1/home/list.md +0 -47
- data/examples/complex-test-app/docs/api/api/v1/notes/create.md +0 -94
- data/examples/complex-test-app/docs/api/api/v1/notes/index.md +0 -10
- data/examples/complex-test-app/docs/api/api/v1/notes/list.md +0 -61
- data/examples/complex-test-app/docs/api/api/v1/orders/cancel.md +0 -69
- data/examples/complex-test-app/docs/api/api/v1/orders/create.md +0 -150
- data/examples/complex-test-app/docs/api/api/v1/orders/destroy.md +0 -37
- data/examples/complex-test-app/docs/api/api/v1/orders/index.md +0 -13
- data/examples/complex-test-app/docs/api/api/v1/orders/list.md +0 -71
- data/examples/complex-test-app/docs/api/api/v1/orders/show.md +0 -83
- data/examples/complex-test-app/docs/api/api/v1/products/index.md +0 -11
- data/examples/complex-test-app/docs/api/api/v1/products/list.md +0 -83
- data/examples/complex-test-app/docs/api/api/v1/products/search.md +0 -88
- data/examples/complex-test-app/docs/api/api/v1/products/show.md +0 -71
- data/examples/complex-test-app/docs/api/api/v1/profiles/index.md +0 -10
- data/examples/complex-test-app/docs/api/api/v1/profiles/show.md +0 -61
- data/examples/complex-test-app/docs/api/api/v1/profiles/update.md +0 -91
- data/examples/complex-test-app/docs/api/api/v2/products/index.md +0 -9
- data/examples/complex-test-app/docs/api/api/v2/products/list.md +0 -77
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/create.sh +0 -18
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/destroy.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/admin/products/list.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/auth/login.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/cart-items/create.sh +0 -16
- data/examples/complex-test-app/docs/api/curl/api/v1/cart-items/destroy.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/carts/checkout.sh +0 -13
- data/examples/complex-test-app/docs/api/curl/api/v1/carts/show.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/home/list.sh +0 -8
- data/examples/complex-test-app/docs/api/curl/api/v1/notes/create.sh +0 -15
- data/examples/complex-test-app/docs/api/curl/api/v1/notes/list.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/cancel.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/create.sh +0 -29
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/destroy.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/list.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/orders/show.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/products/list.sh +0 -8
- data/examples/complex-test-app/docs/api/curl/api/v1/products/search.sh +0 -8
- data/examples/complex-test-app/docs/api/curl/api/v1/products/show.sh +0 -8
- data/examples/complex-test-app/docs/api/curl/api/v1/profiles/show.sh +0 -9
- data/examples/complex-test-app/docs/api/curl/api/v1/profiles/update.sh +0 -16
- data/examples/complex-test-app/docs/api/curl/api/v2/products/list.sh +0 -8
- data/examples/complex-test-app/docs/api/dataset.json +0 -5109
- data/examples/complex-test-app/docs/api/postman/collection.json +0 -2568
- data/examples/complex-test-app/generate.rb +0 -14
- data/examples/complex-test-app/reqcord.yml +0 -28
- data/examples/complex-test-app/test/integration/admin_test.rb +0 -70
- data/examples/complex-test-app/test/integration/cart_test.rb +0 -64
- data/examples/complex-test-app/test/integration/home_and_auth_test.rb +0 -53
- data/examples/complex-test-app/test/integration/orders_test.rb +0 -127
- data/examples/complex-test-app/test/integration/products_test.rb +0 -66
- data/examples/spec-app/.rspec +0 -1
- data/examples/spec-app/README.md +0 -36
- data/examples/spec-app/app.rb +0 -209
- data/examples/spec-app/docs/api/README.md +0 -45
- data/examples/spec-app/docs/api/api/v1/customers/create.md +0 -95
- data/examples/spec-app/docs/api/api/v1/customers/index.md +0 -11
- data/examples/spec-app/docs/api/api/v1/customers/list.md +0 -67
- data/examples/spec-app/docs/api/api/v1/customers/show.md +0 -65
- data/examples/spec-app/docs/api/api/v1/tasks/complete.md +0 -51
- data/examples/spec-app/docs/api/api/v1/tasks/create.md +0 -90
- data/examples/spec-app/docs/api/api/v1/tasks/destroy.md +0 -35
- data/examples/spec-app/docs/api/api/v1/tasks/index.md +0 -14
- data/examples/spec-app/docs/api/api/v1/tasks/list.md +0 -65
- data/examples/spec-app/docs/api/api/v1/tasks/show.md +0 -65
- data/examples/spec-app/docs/api/api/v1/tasks/update.md +0 -74
- data/examples/spec-app/docs/api/api/v1/users/create.md +0 -95
- data/examples/spec-app/docs/api/api/v1/users/index.md +0 -11
- data/examples/spec-app/docs/api/api/v1/users/list.md +0 -67
- data/examples/spec-app/docs/api/api/v1/users/show.md +0 -65
- data/examples/spec-app/docs/api/curl/api/v1/customers/create.sh +0 -17
- data/examples/spec-app/docs/api/curl/api/v1/customers/list.sh +0 -9
- data/examples/spec-app/docs/api/curl/api/v1/customers/show.sh +0 -9
- data/examples/spec-app/docs/api/curl/api/v1/tasks/complete.sh +0 -8
- data/examples/spec-app/docs/api/curl/api/v1/tasks/create.sh +0 -15
- data/examples/spec-app/docs/api/curl/api/v1/tasks/destroy.sh +0 -8
- data/examples/spec-app/docs/api/curl/api/v1/tasks/list.sh +0 -8
- data/examples/spec-app/docs/api/curl/api/v1/tasks/show.sh +0 -8
- data/examples/spec-app/docs/api/curl/api/v1/tasks/update.sh +0 -14
- data/examples/spec-app/docs/api/curl/api/v1/users/create.sh +0 -17
- data/examples/spec-app/docs/api/curl/api/v1/users/list.sh +0 -9
- data/examples/spec-app/docs/api/curl/api/v1/users/show.sh +0 -9
- data/examples/spec-app/docs/api/dataset.json +0 -2402
- data/examples/spec-app/docs/api/postman/collection.json +0 -1290
- data/examples/spec-app/generate.rb +0 -14
- data/examples/spec-app/reqcord.yml +0 -27
- data/examples/spec-app/spec/requests/customers_spec.rb +0 -71
- data/examples/spec-app/spec/requests/tasks_spec.rb +0 -78
- data/examples/spec-app/spec/requests/users_spec.rb +0 -68
- data/examples/spec-app/spec/spec_helper.rb +0 -17
- data/examples/test-app/README.md +0 -57
- data/examples/test-app/app.rb +0 -212
- data/examples/test-app/docs/api/README.md +0 -45
- data/examples/test-app/docs/api/api/v1/customers/create.md +0 -95
- data/examples/test-app/docs/api/api/v1/customers/index.md +0 -11
- data/examples/test-app/docs/api/api/v1/customers/list.md +0 -67
- data/examples/test-app/docs/api/api/v1/customers/show.md +0 -65
- data/examples/test-app/docs/api/api/v1/tasks/complete.md +0 -51
- data/examples/test-app/docs/api/api/v1/tasks/create.md +0 -90
- data/examples/test-app/docs/api/api/v1/tasks/destroy.md +0 -35
- data/examples/test-app/docs/api/api/v1/tasks/index.md +0 -14
- data/examples/test-app/docs/api/api/v1/tasks/list.md +0 -65
- data/examples/test-app/docs/api/api/v1/tasks/show.md +0 -65
- data/examples/test-app/docs/api/api/v1/tasks/update.md +0 -74
- data/examples/test-app/docs/api/api/v1/users/create.md +0 -95
- data/examples/test-app/docs/api/api/v1/users/index.md +0 -11
- data/examples/test-app/docs/api/api/v1/users/list.md +0 -67
- data/examples/test-app/docs/api/api/v1/users/show.md +0 -65
- data/examples/test-app/docs/api/curl/api/v1/customers/create.sh +0 -17
- data/examples/test-app/docs/api/curl/api/v1/customers/list.sh +0 -9
- data/examples/test-app/docs/api/curl/api/v1/customers/show.sh +0 -9
- data/examples/test-app/docs/api/curl/api/v1/tasks/complete.sh +0 -8
- data/examples/test-app/docs/api/curl/api/v1/tasks/create.sh +0 -15
- data/examples/test-app/docs/api/curl/api/v1/tasks/destroy.sh +0 -8
- data/examples/test-app/docs/api/curl/api/v1/tasks/list.sh +0 -8
- data/examples/test-app/docs/api/curl/api/v1/tasks/show.sh +0 -8
- data/examples/test-app/docs/api/curl/api/v1/tasks/update.sh +0 -14
- data/examples/test-app/docs/api/curl/api/v1/users/create.sh +0 -17
- data/examples/test-app/docs/api/curl/api/v1/users/list.sh +0 -9
- data/examples/test-app/docs/api/curl/api/v1/users/show.sh +0 -9
- data/examples/test-app/docs/api/dataset.json +0 -2402
- data/examples/test-app/docs/api/postman/collection.json +0 -1290
- data/examples/test-app/generate.rb +0 -14
- data/examples/test-app/reqcord.yml +0 -28
- data/examples/test-app/test/integration/customers_test.rb +0 -72
- data/examples/test-app/test/integration/tasks_test.rb +0 -80
- data/examples/test-app/test/integration/users_test.rb +0 -72
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Stands in for `bin/rails reqcord:generate`, which this single file example
|
|
4
|
-
# has no `bin/rails` to run.
|
|
5
|
-
require_relative "app"
|
|
6
|
-
|
|
7
|
-
dataset = Reqcord::Generator.call(
|
|
8
|
-
resources: ENV.fetch("RESOURCE", "").split(",").map(&:strip).reject(&:empty?),
|
|
9
|
-
version: ENV["VERSION"]
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
puts
|
|
13
|
-
puts "Endpoints: #{dataset.endpoints.size} (#{dataset.documented_endpoints.size} covered by tests)"
|
|
14
|
-
puts "Output: #{Reqcord.configuration.output_directory}"
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
version: 1
|
|
2
|
-
|
|
3
|
-
test:
|
|
4
|
-
framework: minitest
|
|
5
|
-
# A directory is enough. There is no bin/rails here, so Reqcord runs every
|
|
6
|
-
# *_test.rb beneath it itself; in a Rails app it runs `bin/rails test <path>`.
|
|
7
|
-
paths:
|
|
8
|
-
- test/integration
|
|
9
|
-
|
|
10
|
-
routes:
|
|
11
|
-
prefix: /api
|
|
12
|
-
|
|
13
|
-
output:
|
|
14
|
-
directory: docs/api
|
|
15
|
-
|
|
16
|
-
exporters:
|
|
17
|
-
- curl
|
|
18
|
-
- markdown
|
|
19
|
-
- postman
|
|
20
|
-
|
|
21
|
-
variables:
|
|
22
|
-
base_url: http://localhost:3000
|
|
23
|
-
|
|
24
|
-
sanitize:
|
|
25
|
-
headers:
|
|
26
|
-
Authorization: "Bearer {{token}}"
|
|
27
|
-
body:
|
|
28
|
-
password: "{{password}}"
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Ordinary Rails integration tests. Nothing here mentions Reqcord: the
|
|
4
|
-
# documentation is generated from the requests these tests already make.
|
|
5
|
-
require_relative "../../app"
|
|
6
|
-
require "minitest/autorun"
|
|
7
|
-
|
|
8
|
-
class CustomersTest < ActionDispatch::IntegrationTest
|
|
9
|
-
def auth
|
|
10
|
-
{ "Authorization" => "Bearer eyJhbGciOiJIUzI1NiJ9.super-secret" }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test "lists customers" do
|
|
14
|
-
get "/api/v1/customers", params: { per_page: 1 }, headers: auth, as: :json
|
|
15
|
-
|
|
16
|
-
assert_response :ok
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "shows customer" do
|
|
20
|
-
get "/api/v1/customers/1", headers: auth, as: :json
|
|
21
|
-
|
|
22
|
-
assert_response :ok
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
test "returns not found for an unknown customer" do
|
|
26
|
-
get "/api/v1/customers/999", headers: auth, as: :json
|
|
27
|
-
|
|
28
|
-
assert_response :not_found
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "creates an active customer" do
|
|
32
|
-
post "/api/v1/customers",
|
|
33
|
-
params: { customer: { name: "Ada Lovelace", email: "ada@example.com", status: "active" } },
|
|
34
|
-
headers: auth,
|
|
35
|
-
as: :json
|
|
36
|
-
|
|
37
|
-
assert_response :created
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
test "creates a passive customer" do
|
|
41
|
-
post "/api/v1/customers",
|
|
42
|
-
params: { customer: { name: "Grace Hopper", email: "grace@example.com", status: "passive" } },
|
|
43
|
-
headers: auth,
|
|
44
|
-
as: :json
|
|
45
|
-
|
|
46
|
-
assert_response :created
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
test "rejects an unknown status" do
|
|
50
|
-
post "/api/v1/customers",
|
|
51
|
-
params: { customer: { name: "Ada Lovelace", email: "ada@example.com", status: "inactive" } },
|
|
52
|
-
headers: auth,
|
|
53
|
-
as: :json
|
|
54
|
-
|
|
55
|
-
assert_response :unprocessable_entity
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
test "rejects a customer without an email" do
|
|
59
|
-
post "/api/v1/customers",
|
|
60
|
-
params: { customer: { name: "Ada Lovelace", email: "", status: "active" } },
|
|
61
|
-
headers: auth,
|
|
62
|
-
as: :json
|
|
63
|
-
|
|
64
|
-
assert_response :unprocessable_entity
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
test "requires authentication" do
|
|
68
|
-
get "/api/v1/customers", as: :json
|
|
69
|
-
|
|
70
|
-
assert_response :unauthorized
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Ordinary Rails integration tests. Nothing here mentions Reqcord: the
|
|
4
|
-
# documentation is generated from the requests these tests already make.
|
|
5
|
-
require_relative "../../app"
|
|
6
|
-
require "minitest/autorun"
|
|
7
|
-
|
|
8
|
-
class TasksTest < ActionDispatch::IntegrationTest
|
|
9
|
-
test "lists tasks" do
|
|
10
|
-
get "/api/v1/tasks", as: :json
|
|
11
|
-
|
|
12
|
-
assert_response :ok
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "lists open tasks" do
|
|
16
|
-
get "/api/v1/tasks", params: { status: "open" }, as: :json
|
|
17
|
-
|
|
18
|
-
assert_response :ok
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
test "lists done tasks" do
|
|
22
|
-
get "/api/v1/tasks", params: { status: "done" }, as: :json
|
|
23
|
-
|
|
24
|
-
assert_response :ok
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test "shows a task" do
|
|
28
|
-
get "/api/v1/tasks/1", as: :json
|
|
29
|
-
|
|
30
|
-
assert_response :ok
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
test "returns not found for an unknown task" do
|
|
34
|
-
get "/api/v1/tasks/999", as: :json
|
|
35
|
-
|
|
36
|
-
assert_response :not_found
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
test "creates a high priority task" do
|
|
40
|
-
post "/api/v1/tasks", params: { task: { title: "Review the release", priority: "high" } }, as: :json
|
|
41
|
-
|
|
42
|
-
assert_response :created
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "creates a low priority task" do
|
|
46
|
-
post "/api/v1/tasks", params: { task: { title: "Water the plants", priority: "low" } }, as: :json
|
|
47
|
-
|
|
48
|
-
assert_response :created
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
test "rejects a task without a title" do
|
|
52
|
-
post "/api/v1/tasks", params: { task: { title: "", priority: "high" } }, as: :json
|
|
53
|
-
|
|
54
|
-
assert_response :unprocessable_entity
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
test "rejects an unknown priority" do
|
|
58
|
-
post "/api/v1/tasks", params: { task: { title: "Anything", priority: "urgent" } }, as: :json
|
|
59
|
-
|
|
60
|
-
assert_response :unprocessable_entity
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "updates a task" do
|
|
64
|
-
patch "/api/v1/tasks/1", params: { task: { title: "Write better docs" } }, as: :json
|
|
65
|
-
|
|
66
|
-
assert_response :ok
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
test "completes a task" do
|
|
70
|
-
post "/api/v1/tasks/1/complete", as: :json
|
|
71
|
-
|
|
72
|
-
assert_response :ok
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
test "deletes a task" do
|
|
76
|
-
delete "/api/v1/tasks/3", as: :json
|
|
77
|
-
|
|
78
|
-
assert_response :no_content
|
|
79
|
-
end
|
|
80
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Ordinary Rails integration tests. Nothing here mentions Reqcord: the
|
|
4
|
-
# documentation is generated from the requests these tests already make.
|
|
5
|
-
require_relative "../../app"
|
|
6
|
-
require "minitest/autorun"
|
|
7
|
-
|
|
8
|
-
class UsersTest < ActionDispatch::IntegrationTest
|
|
9
|
-
def auth
|
|
10
|
-
{ "Authorization" => "Bearer eyJhbGciOiJIUzI1NiJ9.super-secret" }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test "lists users" do
|
|
14
|
-
get "/api/v1/users", params: { per_page: 1 }, headers: auth, as: :json
|
|
15
|
-
|
|
16
|
-
assert_response :ok
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "shows user" do
|
|
20
|
-
get "/api/v1/users/1", headers: auth, as: :json
|
|
21
|
-
|
|
22
|
-
assert_response :ok
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
test "returns not found for an unknown user" do
|
|
26
|
-
get "/api/v1/users/999", headers: auth, as: :json
|
|
27
|
-
|
|
28
|
-
assert_response :not_found
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "creates an active user" do
|
|
32
|
-
post "/api/v1/users",
|
|
33
|
-
params: { user: { name: "Ada Lovelace", email: "ada@example.com", status: "active" } },
|
|
34
|
-
headers: auth,
|
|
35
|
-
as: :json
|
|
36
|
-
|
|
37
|
-
assert_response :created
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
test "creates a inactive user" do
|
|
41
|
-
post "/api/v1/users",
|
|
42
|
-
params: { user: { name: "Grace Hopper", email: "grace@example.com", status: "inactive" } },
|
|
43
|
-
headers: auth,
|
|
44
|
-
as: :json
|
|
45
|
-
|
|
46
|
-
assert_response :created
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
test "rejects an unknown status" do
|
|
50
|
-
post "/api/v1/users",
|
|
51
|
-
params: { user: { name: "Ada Lovelace", email: "ada@example.com", status: "passive" } },
|
|
52
|
-
headers: auth,
|
|
53
|
-
as: :json
|
|
54
|
-
|
|
55
|
-
assert_response :unprocessable_entity
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
test "rejects a user without an email" do
|
|
59
|
-
post "/api/v1/users",
|
|
60
|
-
params: { user: { name: "Ada Lovelace", email: "", status: "active" } },
|
|
61
|
-
headers: auth,
|
|
62
|
-
as: :json
|
|
63
|
-
|
|
64
|
-
assert_response :unprocessable_entity
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
test "requires authentication" do
|
|
68
|
-
get "/api/v1/users", as: :json
|
|
69
|
-
|
|
70
|
-
assert_response :unauthorized
|
|
71
|
-
end
|
|
72
|
-
end
|