mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Inline disabling Style/MethodMissing Cop
To make it obvious that these are non-standard cases. Also add respond_to_missing? to the decorator. We are using Style/MethodMissing rather than Style/MethodMissingSuper and Style/MissingRespondToMissing because we are still on RuboCop 0.54.
This commit is contained in:
parent
d9b7c972c3
commit
c71aded778
5 changed files with 8 additions and 11 deletions
|
@ -21,13 +21,6 @@ Style/SymbolArray:
|
|||
Style/FormatStringToken:
|
||||
Enabled: false
|
||||
|
||||
Style/MethodMissing:
|
||||
Exclude:
|
||||
- 'lib/factory_bot/decorator.rb'
|
||||
- 'lib/factory_bot/decorator/invocation_tracker.rb'
|
||||
- 'lib/factory_bot/definition_proxy.rb'
|
||||
- 'lib/factory_bot/evaluator.rb'
|
||||
|
||||
# TODO: gradually bring this down to 80 as we fix files
|
||||
# Let's not open a big PR to fix all of these at once -
|
||||
# we can fix gradually if we happen to be editing a file that has a violation
|
||||
|
|
|
@ -6,10 +6,14 @@ module FactoryBot
|
|||
@component = component
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
|
||||
@component.send(name, *args, &block)
|
||||
end
|
||||
|
||||
def respond_to_missing?(name, include_private = false)
|
||||
@component.respond_to?(name, true) || super
|
||||
end
|
||||
|
||||
def send(symbol, *args, &block)
|
||||
__send__(symbol, *args, &block)
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module FactoryBot
|
|||
@invoked_methods = []
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
|
||||
@invoked_methods << name
|
||||
super
|
||||
end
|
||||
|
|
|
@ -72,7 +72,7 @@ module FactoryBot
|
|||
# end
|
||||
#
|
||||
# are equivalent.
|
||||
def method_missing(name, *args, &block)
|
||||
def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
|
||||
if args.empty?
|
||||
__declare_attribute__(name, block)
|
||||
elsif args.first.respond_to?(:has_key?) && args.first.has_key?(:factory)
|
||||
|
|
|
@ -37,7 +37,7 @@ module FactoryBot
|
|||
@instance = object_instance
|
||||
end
|
||||
|
||||
def method_missing(method_name, *args, &block)
|
||||
def method_missing(method_name, *args, &block) # rubocop:disable Style/MethodMissing
|
||||
if @instance.respond_to?(method_name)
|
||||
@instance.send(method_name, *args, &block)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue