1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Refactor disallows_duplicates_registry_spec.rb to conform to Let's Not style (#1344)

* Refactor disallows_duplicates_registry_spec.rb to conform to Let's Not style

* Remove 'described_class' references
This commit is contained in:
Richie Thomas 2019-10-25 09:53:04 -07:00 committed by GitHub
parent 03e59b4a6d
commit 9b0d29e966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,17 +1,19 @@
describe FactoryBot::Decorator::DisallowsDuplicatesRegistry do
let(:registry) { double("registry", name: "Great thing", register: true) }
subject { described_class.new(registry) }
it "delegates #register to the registry when not registered" do
registry = double("registry", name: "Great thing", register: true)
decorator = FactoryBot::Decorator::DisallowsDuplicatesRegistry.new(registry)
allow(registry).to receive(:registered?).and_return false
subject.register(:awesome, {})
decorator.register(:awesome, {})
expect(registry).to have_received(:register).with(:awesome, {})
end
it "raises when attempting to #register a previously registered strategy" do
registry = double("registry", name: "Great thing", register: true)
decorator = FactoryBot::Decorator::DisallowsDuplicatesRegistry.new(registry)
allow(registry).to receive(:registered?).and_return true
expect { subject.register(:same_name, {}) }.
expect { decorator.register(:same_name, {}) }.
to raise_error(FactoryBot::DuplicateDefinitionError, "Great thing already registered: same_name")
end
end