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:
parent
f9fedc8176
commit
630aca4b87
7 changed files with 15 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue