1. どこをテストするか

2. 何を期待するか

コードの意図(何を確認しているか)

  describe "GET /index" do
    it "記事一覧を取得できる" do
      # テストデータを作成
      article = create(:article)

      # APIリクエストを送信
      get "/api/v1/articles"

      # レスポンスを確認
      expect(response).to have_http_status(:ok)
      expect(json_response).to be_an(Array)
      expect(json_response.first["title"]).to eq(article.title)
      expect(json_response.first["updated_at"]).to be_present
    end
  end

(期待していること)

4. 確認結果

bundle exec rspec spec/requests/api/v1/articles_request_spec.rb:5
Run options: include {:locations=>{"./spec/requests/api/v1/articles_request_spec.rb"=>[5]}}

Api::V1::Articles
  GET /index
    記事一覧を取得できる

Finished in 0.58798 seconds (files took 2.23 seconds to load)
1 example, 0 failures

コードの修正