# encoding: utf-8
require_relative 'spec_helper'
require 'slim'
describe EvilFront::Helpers do
include EvilFront::Helpers
describe 'capitalize_first' do
it 'capitalizes Russian' do
expect(capitalize_first('тест')).to eq 'Тест'
end
end
describe 'disable_mobile_zoom' do
it 'returns viewport meta tag' do
expect(disable_mobile_zoom).to match(/^ ' +
'«a»')
end
it 'escapes HTML' do
expect(flying_quotes('
')).to eq(
' ' +
'«<br>»')
end
end
describe 'auto_flying_quotes' do
it 'set quotes to text' do
expect(auto_flying_quotes('от «a»')).to eq(
'от ' +
'«a»')
end
it 'escapes HTML' do
expect(auto_flying_quotes('от «
»')).to eq(
'от ' +
'«<br>»')
end
end
describe 'ruble' do
it 'returns span' do
expect(ruble).to be_a(String)
end
end
describe 'russian_typograph' do
it 'typographs text inside tags' do
tag = 'а...'.html_safe
expect(russian_typograph(tag)).to eq'а…'
end
it 'escapes HTML' do
expect(russian_typograph('')).to eq '<a>'
end
end
describe 'english_typograph' do
it 'typographs text inside tags' do
tag = 'a...'.html_safe
expect(english_typograph(tag)).to eq 'a…'
end
it 'escapes HTML' do
expect(english_typograph('')).to eq '<a>'
end
end
describe 'typograph_by_locale' do
after do
I18n.locale = :en
end
it 'typographs by current locale' do
I18n.locale = :en
expect(typograph_by_locale('"a"')).to eq '“a”'
I18n.locale = :ru
expect(typograph_by_locale('"a"')).to eq '«a»'
end
it 'returns origin text on unknown locale' do
I18n.locale = :fr
expect(typograph_by_locale('"a"')).to eq '"a"'
end
end
describe 'title' do
after do
I18n.locale = :en
@evil_front_titles = nil
end
it 'shows site name' do
expect(title_tag('Site')).to eq 'Site'
end
it 'shows site names' do
expect(title_tag('One', 'Two')).to eq 'One - Two'
end
it 'shows page name' do
title 'Page', 'Section'
expect(title_tag('Site')).to eq 'Page - Section - Site'
end
it 'shows Russian separator' do
I18n.locale = :ru
title 'Страница', 'Раздел'
expect(title_tag('Сайт')).to eq 'Страница — Раздел — Сайт'
end
it 'shows custom separator' do
title 'One', 'Two'
expect(title_tag(separator: ' | ')).to eq 'One | Two'
end
it 'escapes HTML' do
title ''
expect(title_tag).to eq '<B>'
end
it 'hides site name on request' do
title 'Page', no_site: true
expect(title_tag('Site')).to eq 'Page'
end
end
end