feat: テスト自動化(#104) (#220)
#104 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #220
This commit was merged in pull request #220.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
require 'rails_helper'
|
||||
|
||||
|
||||
RSpec.describe 'Posts API', type: :request do
|
||||
describe 'GET /posts' do
|
||||
it 'returns tags with name in JSON' do
|
||||
tn = TagName.create!(name: 'gen:spec_tag')
|
||||
tag = Tag.create!(tag_name: tn, category: 'general')
|
||||
|
||||
post = Post.create!(title: 'spec post', url: 'https://example.com/spec')
|
||||
PostTag.create!(post: post, tag: tag)
|
||||
|
||||
get '/posts'
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
expect(json).to have_key('posts')
|
||||
expect(json['posts']).to be_a(Array)
|
||||
expect(json['posts']).not_to be_empty
|
||||
|
||||
tags = json['posts'][0]['tags']
|
||||
expect(tags).to be_a(Array)
|
||||
expect(tags).not_to be_empty
|
||||
|
||||
expect(tags[0]).to have_key('name')
|
||||
expect(tags[0]['name']).to eq('gen:spec_tag')
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user