Local Testing

DB Migration

Let’s run the create the database and run the migration.

jets db:create db:migrate

Seeding Data

Let’s create some seed data to help with first. Create this file:


2.times do |i|
  i += 1
  Post.find_or_create_by(title: "Post #{i}", body: "Body #{i}", published: true)
puts "Posts created"

Run jets db:seed

❯ jets db:seed
Posts created

Run jets runner to confirm that the records were created.

❯ jets runner 'puts Post.count'

Start Server

You can test locally with jets server.


❯ jets server
=> Booting Puma
=> Jets 5.0.0 application starting in development
=> Run `jets server --help` for more startup options
Puma starting in single mode...
* Listening on
Use Ctrl-C to stop

A puma web server allows you to test locally just like a normal rack app.

Testing Index Listing

Test by opening localhost:8888/posts in a browser:

On the jets server side, you’ll see the request:

Started GET "/posts" for at 2023-10-28 14:09:35 +0000
Processing PostsController#index
Completed Status Code 200 in 0.015s
Started GET "/posts" for at 2023-10-28 14:09:36 +0000

Test Create

Click on new and create a new post.

On the jets server side:

Started POST "/posts" for at 2023-10-28 14:17:22 +0000
Processing PostsController#create
  Parameters: {"post":{"title":"Post 3","body":"Body 3","published":true}}
Completed Status Code 201 in 0.017s

Test Update

Click on edit and edit an existing post.

On the jets server side

Processing PostsController#update
  Parameters: {"post":{"title":"Post 3 Edit 1","body":"Body 3","published":true},"id":"3"}
Completed Status Code 200 in 0.010s

Test Delete

Last, let’s delete the post.

On the jets server side

Started DELETE "/posts/3" for at 2023-10-28 14:44:20 +0000
Processing PostsController#destroy
  Parameters: {"id":"3"}
Completed Status Code 200 in 0.015s

Next, we’ll deploy the project to AWS Lambda.