Wednesday, July 15, 2026 2:53:52 AM
> server_spec.rb
# frozen_string_literal: true

describe ESM::Server do
  let!(:community) { create(:community) }
  let!(:server) { create(:server, community_id: community.id) }

  describe "#correct" do
    subject(:server_id) { server.server_id }

    context "when the server ID is correct" do
      it "provides no corrections" do
        corrections = ESM::Server.correct_id(server_id)

        expect(corrections).to be_blank
      end
    end

    context "when the server ID is incorrect" do
      let!(:server_id_partial) { server_id[0..Faker::Number.between(from: server_id.size / 2, to: server_id.size - 2)] }

      it "provides a correction" do
        correction = ESM::Server.correct_id(server_id_partial)

        expect(correction).not_to be_blank, "Checking #{server_id_partial.inspect} in #{described_class.server_ids.inspect}"
        expect(correction.first).to eq(server.server_id)
      end
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 43aa0d7