mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
a56b68bc9c
* Alphabetize gem listing in various Gemfiles [Rubocop Bundler/OrderedGems] * Fix alignment of if/else/end statement [Rubocop Layout/ElseAlignment] * Method definitions should have a empty line between them [Rubocop Layout/EmptyLineBetweenDefs] * Modules, Classes, and blocks should have an empty line around them [Rubocop] Cops: Layout/EmptyLinesAroundBlockBody Layout/EmptyLinesAroundModuleBody Layout/EmptyLinesAroundClassBody Layout/EmptyLinesAroundAccessModifier * Keep a blank line before and after access modifiers [Rubocop Layout/EmptyLinesAroundAccessModifier] * Remove misc extra whitespace [Rubocop Layout/ExtraSpacing] * Indent the first line of the right-hand-side of a multi-line assignment [Rubocop Layout/IndentAssignment] * Remove extraneous whitespace [Rubocop] Cops: Layout/IndentationWidth Layout/LeadingCommentSpace Layout/SpaceAroundEqualsInParameterDefault Layout/SpaceInsideArrayLiteralBrackets Layout/SpaceInsideBlockBraces Layout/SpaceInsideParens Layout/TrailingBlankLines * Revert rubocop changes to gemfiles; exclude files from rubocop checks The files in gemfiles/ are generated by Appraisal, so we shouldn't edit them. Instead, let's tell RuboCop to exclude this directory.
29 lines
628 B
Ruby
29 lines
628 B
Ruby
module FactoryBot
|
|
class Declaration
|
|
# @api private
|
|
class Association < Declaration
|
|
def initialize(name, *options)
|
|
super(name, false)
|
|
@options = options.dup
|
|
@overrides = options.extract_options!
|
|
@traits = options
|
|
end
|
|
|
|
def ==(other)
|
|
name == other.name &&
|
|
options == other.options
|
|
end
|
|
|
|
protected
|
|
|
|
attr_reader :options
|
|
|
|
private
|
|
|
|
def build
|
|
factory_name = @overrides[:factory] || name
|
|
[Attribute::Association.new(name, factory_name, [@traits, @overrides.except(:factory)].flatten)]
|
|
end
|
|
end
|
|
end
|
|
end
|