rspec ステーキ gem で I18n html キーをテストするにはどうすればよいですか?
feature 'about page - not signed in user' do
background do
visit '/about'
end
scenario 'visit about page' do
page.should have_content(I18n.t("pages.about.headline_html"))
page.should have_content(I18n.t("pages.about.body_html"))
end
end
私はいつも次のようになります:
..FF
Failures:
1) about page - not signed in user visit about page
Failure/Error: page.should have_content(I18n.t("pages.about.headline_html"))
expected there to be content "<h1>About</h1>" in "About"
誰でもアイデアはありますか?
私はすでに試しました:
page.should have_content(I18n.t("pages.about.headline_html").html_safe)
編集:私が含める場合
include ActionView::Helpers::SanitizeHelper
私の機能に、私はそれが好きです:
headline = strip_tags(I18n.t("pages.about.headline_html"))
body = strip_tags(I18n.t("pages.about.body_html"))
page.should have_content(headline)
page.should have_content(body)
すべてが機能します。
このソリューションについてどう思いますか? 少しハッキーなようです..