Skip to content

Commit e297078

Browse files
committed
refactor: ニュースセクションのテストを改善
- 特定記事に依存しないテストに変更 - /#news での表示機能をテスト - ファクトリーを使用してメンテナンス性向上
1 parent 848eda1 commit e297078

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

spec/features/news_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# -*- coding: utf-8 -*-
22
require 'rails_helper'
33

4-
RSpec.feature "News", type: :feature do
5-
describe "GET /news/2016/12/12/new-backend" do
6-
scenario "Title should be formatted" do
7-
visit "/docs/post-backend-update-history"
8-
expect(page).to have_title "CoderDojo Japan のバックエンド刷新"
4+
RSpec.feature "NewsSection", type: :feature do
5+
let!(:news_item) { create(:news) }
6+
7+
scenario "ニュースセクションにニュース項目が表示される" do
8+
visit root_path(anchor: 'news')
9+
10+
within 'section#news' do
11+
expect(page).to have_link(href: news_item.url)
12+
expect(page).to have_content(news_item.title)
13+
expect(page).to have_selector("a[target='_blank']")
914
end
1015
end
1116
end

0 commit comments

Comments
 (0)