Sha256: c7ef8cc690dcae19c7d519a97b7a60a6a37c98e2fad56d6e328a60ac802a53e6

Contents?: true

Size: 1.69 KB

Versions: 21

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

RSpec.describe YARD::I18n::Messages do
  def message(id)
    YARD::I18n::Message.new(id)
  end

  def messages
    YARD::I18n::Messages.new
  end

  before do
    @messages = messages
  end

  describe "#each" do
    it "enumerates messages" do
      @messages.register("Hello World!")
      @messages.register("Title")
      enumerated_messages = []
      @messages.each do |message|
        enumerated_messages << message
      end
      enumerated_messages = enumerated_messages.sort_by(&:id)
      expect(enumerated_messages).to eq [message("Hello World!"), message("Title")]
    end

    it "does not yield any message if there are none" do
      enumerated_messages = []
      @messages.each do |message|
        enumerated_messages << message
      end
      expect(enumerated_messages).to eq []
    end
  end

  describe "#[]" do
    it "returns registered message" do
      @messages.register("Hello World!")
      expect(@messages["Hello World!"]).to eq message("Hello World!")
    end

    it "returns nil for nonexistent message ID" do
      expect(@messages["Hello World!"]).to eq nil
    end
  end

  describe "#register" do
    it "returns registered message" do
      expect(@messages.register("Hello World!")).to eq message("Hello World!")
    end

    it "returns existent message" do
      message = @messages.register("Hello World!")
      expect(@messages.register("Hello World!").object_id).to eq message.object_id
    end
  end

  describe "#==" do
    it "returns true for same value messages" do
      @messages.register("Hello World!")
      other_messages = messages
      other_messages.register("Hello World!")
      expect(@messages).to eq other_messages
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/i18n/messages_spec.rb
yard-0.9.23 spec/i18n/messages_spec.rb
yard-0.9.22 spec/i18n/messages_spec.rb
yard-0.9.21 spec/i18n/messages_spec.rb
yard-0.9.20 spec/i18n/messages_spec.rb
yard-0.9.19 spec/i18n/messages_spec.rb
yard-0.9.16 spec/i18n/messages_spec.rb
yard-0.9.15 spec/i18n/messages_spec.rb
yard-0.9.14 spec/i18n/messages_spec.rb
yard-0.9.13 spec/i18n/messages_spec.rb
yard-0.9.12 spec/i18n/messages_spec.rb
yard-0.9.11 spec/i18n/messages_spec.rb
yard-0.9.10 spec/i18n/messages_spec.rb
yard-0.9.9 spec/i18n/messages_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/i18n/messages_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/i18n/messages_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/i18n/messages_spec.rb
yard-0.9.8 spec/i18n/messages_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/i18n/messages_spec.rb
yard-0.9.7 spec/i18n/messages_spec.rb