Sha256: bb5755847969e470ad96de515f1c761a19e78768583f5f043026d3aea3d772c2

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8
require "spec_helper"

module Hexx
  describe Helpers::Messages do

    before  { class Test; include Helpers::Messages; end }
    subject { Test.new }
    after   { Hexx.send :remove_const, :Test }

    describe "#t" do

      let(:scope)      { %w(activemodel messages models hexx/test) }
      let(:traslation) { I18n.t(:text, scope: scope, name: "name") }

      it "translates symbols in the service scope" do
        expect(subject.t(:text, name: "name")).to eq traslation
      end

      it "doesn't translate the string" do
        expect(subject.t("text")).to eq "text"
      end
    end

    describe "#messages" do

      it "returns an array" do
        expect(subject.messages).to be_kind_of Array
      end
    end

    describe "#add_message" do

      before        { subject.add_message :info, :text }
      let(:message) { subject.messages.first }

      it "adds a new message" do
        expect(message).to be_kind_of Hexx::Message
        expect(message.type).to eq "info"
      end

      it "translates a symbol" do
        translation = subject.t :text
        expect(message.text).to eq translation
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hexx-7.1.0 spec/hexx/helpers/messages_spec.rb
hexx-7.0.1 spec/hexx/helpers/messages_spec.rb