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:
parent
03e59b4a6d
commit
9b0d29e966
1 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue