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,42 @@
|
||||
require 'cgi'
|
||||
require 'rails_helper'
|
||||
require 'securerandom'
|
||||
|
||||
|
||||
RSpec.describe 'Wiki API', type: :request do
|
||||
let!(:user) { create_user_for_wiki! }
|
||||
|
||||
let!(:tn) { TagName.create!(name: 'spec_wiki_title') }
|
||||
let!(:page) do
|
||||
WikiPage.create!(tag_name: tn, created_user: user, updated_user: user)
|
||||
end
|
||||
|
||||
describe 'GET /wiki' do
|
||||
it 'returns wiki pages with title' do
|
||||
get '/wiki'
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
expect(json).to be_a(Array)
|
||||
expect(json).not_to be_empty
|
||||
|
||||
expect(json[0]).to have_key('title')
|
||||
expect(json.map { |p| p['title'] }).to include('spec_wiki_title')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /wiki/title/:title' do
|
||||
it 'returns wiki page by title' do
|
||||
get "/wiki/title/#{CGI.escape('spec_wiki_title')}"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
expect(json).to have_key('id')
|
||||
expect(json).to have_key('title')
|
||||
expect(json['id']).to eq(page.id)
|
||||
expect(json['title']).to eq('spec_wiki_title')
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user