Sha256: e0b9051efe819993724f540b32facbda5b0034f7b3534f999cb06afd8dd5d654

Contents?: true

Size: 1.17 KB

Versions: 23

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      module FactoryBot
        # @!parse
        #   # Checks for create_list usage.
        #   #
        #   # This cop can be configured using the `EnforcedStyle` option
        #   #
        #   # @example `EnforcedStyle: create_list` (default)
        #   #   # bad
        #   #   3.times { create :user }
        #   #
        #   #   # good
        #   #   create_list :user, 3
        #   #
        #   #   # bad
        #   #   3.times { create :user, age: 18 }
        #   #
        #   #   # good - index is used to alter the created models attributes
        #   #   3.times { |n| create :user, age: n }
        #   #
        #   #   # good - contains a method call, may return different values
        #   #   3.times { create :user, age: rand }
        #   #
        #   # @example `EnforcedStyle: n_times`
        #   #   # bad
        #   #   create_list :user, 3
        #   #
        #   #   # good
        #   #   3.times { create :user }
        #   #
        #   class CreateList < ::RuboCop::Cop::Base; end
        CreateList = ::RuboCop::Cop::FactoryBot::CreateList
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.22.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-2.22.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb
rubocop-rspec-2.22.0 lib/rubocop/cop/rspec/factory_bot/create_list.rb