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