Search⌘ K
AI Features

Challenge: Create a New Blog Post

Explore how to implement request tests for creating and listing blog posts in Rails. Learn to handle the test scenario involving a BlogPost model with title and body, and practice passing request tests without needing user authentication.

We'll cover the following...

Problem statement

You’re given the following test scenario:

Ruby
RSpec.describe "Blog posts", type: :request do
describe "POST /blog_posts" do
it "creates a blog post in the database" do
params = { title: "This is a post", body: "This is the post's body" }
post blog_posts_path, params: { blog_post: params }
expect(BlogPost.count).to eq(1)
end
end
end

Here’s some information to ...