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

Fix violations for latest version of standard

This commit is contained in:
Daniel Colson 2021-02-20 16:55:25 -05:00
parent f9fedc8176
commit 630aca4b87
7 changed files with 15 additions and 17 deletions

View file

@ -30,7 +30,7 @@ module FactoryBot
end
def to_create(&block)
if block_given?
if block
@to_create = block
else
aggregate_from_traits_and_self(:to_create) { @to_create }.last

View file

@ -25,7 +25,7 @@ module FactoryBot
raise key_error_with_custom_message(e)
end
alias [] find
alias_method :[], :find
def register(name, item)
@items[name] = item

View file

@ -15,7 +15,7 @@ module FactoryBot
def factory(name, options = {}, &block)
factory = Factory.new(name, options)
proxy = FactoryBot::DefinitionProxy.new(factory.definition)
proxy.instance_eval(&block) if block_given?
proxy.instance_eval(&block) if block
Internal.register_factory(factory)

View file

@ -9,7 +9,7 @@ module FactoryBot
@definition = Definition.new(@name)
proxy = FactoryBot::DefinitionProxy.new(@definition)
if block_given?
if block
proxy.instance_eval(&@block)
end
end

View file

@ -6,15 +6,14 @@ describe FactoryBot::Attribute::Association do
subject { FactoryBot::Attribute::Association.new(name, factory, overrides) }
module MissingMethods
def association(*args)
end
end
before do
# Define an '#association' instance method allowing it to be mocked.
# Ususually this is determined via '#method_missing'
subject.extend(MissingMethods)
missing_methods = Module.new {
def association(*args)
end
}
subject.extend(missing_methods)
allow(subject)
.to receive(:association).with(any_args).and_return association

View file

@ -26,15 +26,14 @@ describe FactoryBot::Attribute::Dynamic do
let(:block) { -> { attribute_defined_on_attribute } }
let(:result) { "other attribute value" }
module MissingMethods
def attribute_defined_on_attribute(*args)
end
end
before do
# Define an '#attribute_defined_on_attribute' instance method allowing it
# be mocked. Ususually this is determined via '#method_missing'
subject.extend(MissingMethods)
missing_methods = Module.new {
def attribute_defined_on_attribute(*args)
end
}
subject.extend(missing_methods)
allow(subject)
.to receive(:attribute_defined_on_attribute).and_return result

View file

@ -3,7 +3,7 @@ require "active_record"
module DefineConstantMacros
def define_class(path, base = Object, &block)
const = stub_const(path, Class.new(base))
const.class_eval(&block) if block_given?
const.class_eval(&block) if block
const
end