Sha256: 113fdcaec0d259cb1d95a68e450d513203058dba64207b9007fb402b0662c2eb
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require 'spec_helper' require 'it' describe It::Parser do describe '#process' do it 'calls the Interpolation as required' do values = {'b' => It.tag(:b), 'link' => '/messages'} parser = It::Parser.new('You have %{b:%{link:new messages}}!', values) return1 = double('It::Interpolation', process: '<a href="/messages">new messages</a>') It::Interpolation.should_receive(:new).with('%{link:new messages}', values).and_return(return1) return2 = double('It::Interpolation', process: '<b><a href="/messages">new messages</a></b>') It::Interpolation.should_receive(:new).with('%{b:<a href="/messages">new messages</a>}', values).and_return(return2) expect(parser.process).to eq('You have <b><a href="/messages">new messages</a></b>!') end it 'escapes HTML in the string and the labels' do parser = It::Parser.new('It is a <b>save</b> %{word:<i>world</i>}', 'word' => It.tag(:i)) expect(parser.process).to eq('It is a <b>save</b> <i><i>world</i></i>') end it 'marks the result as html safe' do parser = It::Parser.new('test', {}) expect(parser.process).to be_html_safe end it 'delegates pluralization to I18n' do I18n.backend.stub(:pluralize).with('en', {other: 'You have %{count} messages'}, 2) { 'This is the pluralized string' } parser = It::Parser.new({other: 'You have %{count} messages'}, 'locale' => 'en', 'count' => 2) expect(parser.process).to eq('This is the pluralized string') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
it-0.2.5 | spec/it/parser_spec.rb |