Skip to content

Initial value for sequences having no effect #1724

Description

@tgentry-bamboo

Description

Hello! I was reading the documentation on restricting the sequence to an initial starting value. Following the documentation as written has no effect.

Reproduction Steps

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  gem "factory_bot", "6.4.6"
  gem "activerecord"
  gem "sqlite3"
end

require "active_record"
require "factory_bot"
require "minitest/autorun"
require "logger"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
  create_table :posts, force: true do |t|
    t.integer :number_of_characters
  end
end

class Post < ActiveRecord::Base
end

FactoryBot.define do
  factory :post do
    sequence(:body, 1)
  end
end

class FactoryBotTest < Minitest::Test
  def test_factory_bot_stuff
    post = FactoryBot.create(:post)

    assert_equal post.number_of_characters, 1
  end
end

Expected behavior

The sequence starts with the integer 1.

Actual behavior

The sequence starts with the integer 4.

System configuration

6.4.6:
6.1.7.7:
3.1.5:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions