|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | 3 | RSpec.describe ApplicationHelper, type: :helper do |
4 | | - describe '#format_news_title' do |
5 | | - it '先頭文字が絵文字ならそのまま返す' do |
6 | | - news = double('news', title: '🔔 新着', url: 'https://news.coderdojo.jp/123') |
7 | | - expect(helper.format_news_title(news)).to eq '🔔 新着' |
8 | | - end |
9 | | - |
10 | | - context '先頭文字が絵文字でない場合' do |
11 | | - it 'ポッドキャストのURLには📻を付与する' do |
12 | | - news = double('news', title: 'エピソード33', url: 'https://coderdojo.jp/podcasts/33') |
13 | | - expect(helper.format_news_title(news)).to eq '📻 エピソード33' |
14 | | - end |
15 | | - |
16 | | - it 'PR TIMESのURLには📢を付与する' do |
17 | | - news = double('news', title: 'プレスリリース', url: 'https://prtimes.jp/main/html/rd/p/000000001.000038935.html') |
18 | | - expect(helper.format_news_title(news)).to eq '📢 プレスリリース' |
19 | | - end |
20 | | - |
21 | | - it 'その他のURLには📰を付与する' do |
22 | | - news = double('news', title: '更新情報', url: 'https://news.coderdojo.jp/2025/12/06/dojoletter') |
23 | | - expect(helper.format_news_title(news)).to eq '📰 更新情報' |
24 | | - end |
25 | | - end |
26 | | - end |
27 | | - |
28 | | - describe '#news_link_url' do |
29 | | - it 'ポッドキャストの絶対URLを相対パスに変換する' do |
30 | | - news = double('news', url: 'https://coderdojo.jp/podcasts/33') |
31 | | - expect(helper.news_link_url(news)).to eq '/podcasts/33' |
32 | | - end |
33 | | - |
34 | | - it 'その他のURLはそのまま返す' do |
35 | | - news = double('news', url: 'https://news.coderdojo.jp/2025/12/06/dojoletter') |
36 | | - expect(helper.news_link_url(news)).to eq 'https://news.coderdojo.jp/2025/12/06/dojoletter' |
37 | | - |
38 | | - news2 = double('news', url: 'https://prtimes.jp/main/html/rd/p/000000001.000038935.html') |
39 | | - expect(helper.news_link_url(news2)).to eq 'https://prtimes.jp/main/html/rd/p/000000001.000038935.html' |
40 | | - end |
41 | | - end |
| 4 | + # News関連のメソッドはNewsモデルに移動しました |
| 5 | + # spec/models/news_spec.rb を参照 |
42 | 6 | end |
0 commit comments