Sha256: 47ab02a350658a82bcc42f167dcace3c8a82608d28aa2604e1de898602d44ebb

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

module Services
  class NoticeHandler
  end
end

describe Controll::Notify::Message::Translator do
  subject { Controll::Notify::Message::Translator.new caller, message }

  let(:caller)     { Services::NoticeHandler.new }
  let(:message)    { Controll::Notify::Message.new key, options  }
  let(:key)        { :signed_out }
  let(:options) do
    {:name => 'kris'}
  end

  describe '.initialize caller, message' do
    its(:caller)  { should == caller }
    its(:key)     { should == key }
    its(:key)     { should == message.text }
    its(:options) { should == message.options }
    its(:options) { should == options }

    context 'I18n messages with args' do
      let(:name)  { 'kris' }

      before do
       ::I18n.backend.store_translations :en,
         :services => {
           :notice => {
             :signed_out => "Hey %{name}, you have been signed out!"
            }
          }
      end

      after do
       ::I18n.backend.reload!
      end

      specify do
        subject.translate.should == "Hey #{name}, you have been signed out!"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
controll-0.3.2 spec/controll/notify/message/translator_spec.rb
controll-0.3.1 spec/controll/notify/message/translator_spec.rb
controll-0.3.0 spec/controll/notify/message/translator_spec.rb