Sha256: 9b6d9d418896dc6ca4b26c1ba3b1844cff531088f5f9a5b83c77cc1035b87274

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

##############################################################################
#                             Factory Bot Plugin
##############################################################################

begin
  require 'factory_bot'

  FactoryBot.definition_file_paths << './spec/factories'

  if FactoryBot.configuration.factories.count.zero? &&
     Rails.application.class.name.match(/Dummy/)

    FactoryBot.find_definitions
  end

  RSpec.configure do |config|
    config.include FactoryBot::Syntax::Methods

    config.before(:suite) do
      FactoryBot.reload

      FactoryBot.define do
        sequence(:uuid) do |_n|
          SecureRandom.uuid
        end

        sequence(:email) do |n|
          "user#{n}@example.com"
        end

        sequence(:username) do |n|
          "username#{n}"
        end

        sequence(:token) do
          SecureRandom.hex(16)
        end

        sequence(:auth_token) do
          Base64.strict_encode64(SecureRandom.hex(32))
        end
      end
    end

    config.before(:each) do
      FactoryBot.rewind_sequences if FactoryBot.respond_to?(:rewind_sequences)
    end
  end
rescue LoadError
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspeckled-0.0.50 lib/rspeckled/plugins/factory_bot.rb
rspeckled-0.0.49 lib/rspeckled/plugins/factory_bot.rb
rspeckled-0.0.48 lib/rspeckled/plugins/factory_bot.rb
rspeckled-0.0.47 lib/rspeckled/plugins/factory_bot.rb
rspeckled-0.0.46 lib/rspeckled/plugins/factory_bot.rb
rspeckled-0.0.45 lib/rspeckled/plugins/factory_bot.rb