Skip to content

Commit

Permalink
test: add tests for new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvinciguerra committed Mar 27, 2024
1 parent d4c4457 commit c99b6ee
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion spec/brazil_cep/adapters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# frozen_string_literal: true

require "spec_helper"

RSpec.describe Brazil::Cep::Adapters do
it { expect(1.to_s).to eq("1") }
describe ".providers" do
it "returns a list of providers" do
expect(described_class.providers).to include(
viacep: described_class::Viacep,
postmon: described_class::Postmon,
republica_virtual: described_class::RepublicaVirtual
)
end
end

describe ".register" do
it "registers a provider" do
Brazil::Cep::Adapters::CustomProvider = Class.new(Brazil::Cep::Adapters::Base) do
end

described_class.register(:custom_provider, described_class::CustomProvider)

expect(described_class.providers).to include(custom_provider: described_class::CustomProvider)
end
end

describe ".get" do
it "returns a default (viacep) provider instance" do
expect(described_class.get).to be_a(described_class::Viacep)
end

it { expect(described_class.get(:postmon)).to be_a(described_class::Postmon) }

it { expect(described_class.get(:republica_virtual)).to be_a(described_class::RepublicaVirtual) }
end
end

0 comments on commit c99b6ee

Please sign in to comment.