Sha256: e1ba23a6227679c2a3ca8530e272b79fc5a6587b88e64a392aacd9b205d119a1

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

Contents

# coding: utf-8
$KCODE = 'U'

require 'spec_helper'
require 'generators/i18n_translation/lib/translator'

describe I27r::Translator do
  subject { I27r::Translator.new 'ja' }

  describe 'when successfully translated' do
    before do
      subject.stub!(:_translate).and_return('こんにちは')
    end

    it 'returns translated text' do
      subject.translate('hello').should == 'こんにちは'
    end
  end

  describe 'when translation failed with error code' do
    before do
      subject.stub!(:_translate).and_return('')
    end

    it 'returns the original text' do
      subject.translate('hello').should == 'hello'
    end
  end

  describe 'when translation raised an error' do
    before do
      subject.stub!(:_translate).and_raise('ERROR!')
    end

    it 'returns the original text' do
      subject.translate('hello').should == 'hello'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n_generators-1.2.1 spec/translator_spec.rb
i18n_generators-1.2.0 spec/translator_spec.rb