repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attributes_for_destructuring.rb
spec/acceptance/attributes_for_destructuring.rb
describe "Ruby 3.0: attributes_for destructuring syntax" do include FactoryBot::Syntax::Methods before do define_model("User", name: :string) FactoryBot.define do factory :user do sequence(:email) { "email_#{_1}@example.com" } name { "John Doe" } end end end it "suppor...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
describe "syntax methods within dynamic attributes" do before do define_model("Post", title: :string, user_id: :integer) do belongs_to :user def generate "generate result" end end define_model("User", email: :string) FactoryBot.define do sequence(:email_address) { |n|...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/modify_factories_spec.rb
spec/acceptance/modify_factories_spec.rb
describe "modifying factories" do include FactoryBot::Syntax::Methods before do define_model("User", name: :string, admin: :boolean, email: :string, login: :string) FactoryBot.define do sequence(:email) { |n| "user#{n}@example.com" } factory :user do email after(:create) do |...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/activesupport_instrumentation_spec.rb
spec/acceptance/activesupport_instrumentation_spec.rb
unless ActiveSupport::Notifications.respond_to?(:subscribed) module SubscribedBehavior def subscribed(callback, *args) subscriber = subscribe(*args, &callback) yield ensure unsubscribe(subscriber) end end ActiveSupport::Notifications.extend SubscribedBehavior end describe "using Ac...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/sequence_context_spec.rb
spec/acceptance/sequence_context_spec.rb
describe "sequences are evaluated in the correct context, directly & implicitly" do include FactoryBot::Syntax::Methods before do define_class("User") do attr_accessor :id, :name def awesome "aw yeah" end end end it "builds a sequence calling sprintf correctly" do Factor...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/transient_attributes_spec.rb
spec/acceptance/transient_attributes_spec.rb
describe "transient attributes" do before do define_model("User", name: :string, email: :string) FactoryBot.define do sequence(:name) { |n| "John #{n}" } factory :user do transient do four { 2 + 2 } rockstar { true } upcased { false } end na...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/create_spec.rb
spec/acceptance/create_spec.rb
describe "a created instance" do include FactoryBot::Syntax::Methods before do define_model("User") define_model("Post", user_id: :integer) do belongs_to :user end FactoryBot.define do factory :user factory :post do user end end end subject { create("post...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/traits_spec.rb
spec/acceptance/traits_spec.rb
describe "an instance generated by a factory with multiple traits" do before do define_model("User", name: :string, admin: :boolean, gender: :string, email: :string, date_of_birth: :date, great: :string) FactoryBot.define do factory :user do name { "John" } ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/build_list_spec.rb
spec/acceptance/build_list_spec.rb
describe "build multiple instances" do before do define_model("Post", title: :string, position: :integer) FactoryBot.define do factory(:post) do |post| post.title { "Through the Looking Glass" } post.position { rand(10**4) } end end end context "without default attributes...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/reload_spec.rb
spec/acceptance/reload_spec.rb
describe "reload" do it "does not reset the value of use_parent_strategy" do custom_strategy = :custom_use_parent_strategy_value with_temporary_assignment(FactoryBot, :use_parent_strategy, custom_strategy) do FactoryBot.reload expect(FactoryBot.use_parent_strategy).to eq custom_strategy end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/add_attribute_spec.rb
spec/acceptance/add_attribute_spec.rb
describe "#add_attribute" do it "assigns attributes for reserved words on .build" do define_model("Post", title: :string, sequence: :string, new: :boolean) FactoryBot.define do factory :post do add_attribute(:title) { "Title" } add_attribute(:sequence) { "Sequence" } add_attribu...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attribute_existing_on_object_spec.rb
spec/acceptance/attribute_existing_on_object_spec.rb
describe "declaring attributes on a Factory that are private methods on Object" do before do define_model("Website", system: :boolean, link: :string, sleep: :integer) FactoryBot.define do factory :website do system { false } link { "http://example.com" } sleep { 15 } end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/lint_spec.rb
spec/acceptance/lint_spec.rb
describe "FactoryBot.lint" do it "raises when a factory is invalid" do define_model "User", name: :string do validates :name, presence: true end define_model "AlwaysValid" FactoryBot.define do factory :user do factory :admin_user end factory :always_valid end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/parent_spec.rb
spec/acceptance/parent_spec.rb
describe "an instance generated by a factory that inherits from another factory" do before do define_model("User", name: :string, admin: :boolean, email: :string, upper_email: :string, login: :string) FactoryBot.define do factory :user do name { "John" } email { "#{name.downcase}@exampl...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/overrides_spec.rb
spec/acceptance/overrides_spec.rb
describe "attribute overrides" do before do define_model("User", admin: :boolean) define_model("Post", title: :string, secure: :boolean, user_id: :integer) do belongs_to :user def secure=(value) return unless user&.admin? write_attribute(:secure, value) end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/enum_traits_spec.rb
spec/acceptance/enum_traits_spec.rb
describe "enum traits" do def define_model_with_enum(class_name, field, values) define_model(class_name, status: :integer) do if ActiveRecord::VERSION::STRING >= "7.0" enum field, values else enum field => values end end end context "when automatically_define_enum_traits...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/definition_camel_string_spec.rb
spec/acceptance/definition_camel_string_spec.rb
describe "an instance generated by a factory named a camel case string " do before do define_model("UserModel") FactoryBot.define do factory "UserModel", class: UserModel end end it "registers the UserModel factory" do expect(FactoryBot::Internal.factory_by_name("UserModel")) .to be_...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/global_initialize_with_spec.rb
spec/acceptance/global_initialize_with_spec.rb
describe "global initialize_with" do before do define_class("User") do attr_accessor :name def initialize(name) @name = name end end define_class("Post") do attr_reader :name def initialize(name) @name = name end end FactoryBot.define do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/sequence_setting_spec.rb
spec/acceptance/sequence_setting_spec.rb
describe "FactoryBot.set_sequence" do include FactoryBot::Syntax::Methods describe "on success" do describe "setting sequence to correct value" do it "works with Integer sequences" do FactoryBot.define do sequence(:email) { |n| "somebody#{n}@example.com" } end expect(ge...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/defining_methods_inside_a_factory_spec.rb
spec/acceptance/defining_methods_inside_a_factory_spec.rb
describe "defining methods inside FactoryBot" do it "raises with a meaningful message" do define_model("User") bad_factory_definition = -> do FactoryBot.define do factory :user do def generate_name "John Doe" end end end end expect(&bad_fac...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/global_to_create_spec.rb
spec/acceptance/global_to_create_spec.rb
describe "global to_create" do before do define_model("User", name: :string) define_model("Post", name: :string) FactoryBot.define do to_create { |instance| instance.name = "persisted!" } trait :override_to_create do to_create { |instance| instance.name = "override" } end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/create_list_spec.rb
spec/acceptance/create_list_spec.rb
describe "create multiple instances" do before do define_model("Post", title: :string, position: :integer) FactoryBot.define do factory(:post) do |post| post.title { "Through the Looking Glass" } post.position { rand(10**4) } end end end context "without default attribute...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/private_attributes_spec.rb
spec/acceptance/private_attributes_spec.rb
describe "setting private attributes" do it "raises a NoMethodError" do define_class("User") do private attr_accessor :foo end FactoryBot.define do factory :user do foo { 123 } end end expect { FactoryBot.build(:user) }.to raise_error NoMethodError, /fo...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/initialize_with_spec.rb
spec/acceptance/initialize_with_spec.rb
describe "initialize_with with non-FG attributes" do include FactoryBot::Syntax::Methods before do define_model("User", name: :string, age: :integer) do def self.construct(name, age) new(name: name, age: age) end end FactoryBot.define do factory :user do initialize_wi...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/definition_spec.rb
spec/acceptance/definition_spec.rb
describe "an instance generated by a factory with a custom class name" do before do define_model("User", admin: :boolean) FactoryBot.define do factory :user factory :admin, class: User do admin { true } end end end subject { FactoryBot.create(:admin) } it { should be_ki...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/associations_spec.rb
spec/acceptance/associations_spec.rb
describe "associations" do context "when accidentally using an implicit declaration for the factory" do it "raises an error" do define_class("Post") FactoryBot.define do factory :post do author factory: user end end expect { FactoryBot.build(:post) }.to raise_er...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/sequence_spec.rb
spec/acceptance/sequence_spec.rb
describe "sequences" do include FactoryBot::Syntax::Methods require "ostruct" # = On Success # ====================================================================== # describe "on success" do it "generates several values in the correct format" do define_class("User") { attr_accessor :email } ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attributes_for_spec.rb
spec/acceptance/attributes_for_spec.rb
if RUBY_ENGINE != "truffleruby" require_relative "attributes_for_destructuring" end describe "a generated attributes hash" do include FactoryBot::Syntax::Methods before do define_model("User") define_model("Comment") define_model("Post", title: :string, body: :string, summary: :string, ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/skip_create_spec.rb
spec/acceptance/skip_create_spec.rb
describe "skipping the default create" do before do define_model("User", email: :string) FactoryBot.define do factory :user do skip_create email { "john@example.com" } end end end it "doesn't execute anything when creating the instance" do expect(FactoryBot.create(:u...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/create_pair_spec.rb
spec/acceptance/create_pair_spec.rb
describe "create multiple instances" do before do define_model("Post", title: :string, position: :integer) FactoryBot.define do factory(:post) do |post| post.title { "Through the Looking Glass" } post.position { rand(10**4) } end end end context "without default attribute...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/build_stubbed_spec.rb
spec/acceptance/build_stubbed_spec.rb
describe "a generated stub instance" do include FactoryBot::Syntax::Methods before do define_model("User") define_model("Post", title: :string, body: :string, age: :integer, user_id: :integer, draft: :boolean) do belongs_to :user end FactoryBot.define do factor...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/define_child_before_parent_spec.rb
spec/acceptance/define_child_before_parent_spec.rb
describe "defining a child factory before a parent" do before do define_model("User", name: :string, admin: :boolean, email: :string, upper_email: :string, login: :string) FactoryBot.define do factory :admin, parent: :user do admin { true } end factory :user do name { "awes...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/modify_inherited_spec.rb
spec/acceptance/modify_inherited_spec.rb
describe "modifying inherited factories with traits" do before do define_model("User", gender: :string, admin: :boolean, age: :integer) FactoryBot.define do factory :user do trait(:female) { gender { "Female" } } trait(:male) { gender { "Male" } } trait(:young_admin) do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/definition_without_block_spec.rb
spec/acceptance/definition_without_block_spec.rb
describe "an instance generated by a factory" do before do define_model("User") FactoryBot.define do factory :user end end it "registers the user factory" do expect(FactoryBot::Internal.factory_by_name(:user)) .to be_a(FactoryBot::Factory) end end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/register_strategies_spec.rb
spec/acceptance/register_strategies_spec.rb
shared_context "registering custom strategies" do before do define_class("NamedObject") do attr_accessor :name end end let(:custom_strategy) do Class.new do def result(evaluation) evaluation.object.tap do |instance| instance.name = "Custom strategy" end end...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attributes_ordered_spec.rb
spec/acceptance/attributes_ordered_spec.rb
describe "a generated attributes hash where order matters" do include FactoryBot::Syntax::Methods before do define_model("ParentModel", static: :integer, evaluates_first: :integer, evaluates_second: :integer, evaluates_third: :integer) FactoryBot.define do factory :parent_model do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attribute_aliases_spec.rb
spec/acceptance/attribute_aliases_spec.rb
describe "attribute aliases" do around do |example| original_aliases = FactoryBot.aliases.dup example.run ensure FactoryBot.aliases.clear FactoryBot.aliases.concat(original_aliases) end describe "basic alias functionality" do it "allows using different parameter names that map to model attr...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/internal_spec.rb
spec/factory_bot/internal_spec.rb
describe FactoryBot::Internal do describe ".register_trait" do it "registers the provided trait" do trait = FactoryBot::Trait.new(:admin) configuration = FactoryBot::Internal.configuration expect { FactoryBot::Internal.register_trait(trait) } .to change { configuration.traits.count } ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/null_factory_spec.rb
spec/factory_bot/null_factory_spec.rb
describe FactoryBot::NullFactory do it "delegates defined traits to its definition" do null_factory = FactoryBot::NullFactory.new expect(null_factory).to delegate(:defined_traits).to(:definition) end it "delegates callbacks to its definition" do null_factory = FactoryBot::NullFactory.new expect...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/disallows_duplicates_registry_spec.rb
spec/factory_bot/disallows_duplicates_registry_spec.rb
describe FactoryBot::Decorator::DisallowsDuplicatesRegistry do it "delegates #register to the registry when not registered" do registry = double("registry", name: "Great thing", register: true) decorator = FactoryBot::Decorator::DisallowsDuplicatesRegistry.new(registry) allow(registry).to receive(:registe...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/evaluator_class_definer_spec.rb
spec/factory_bot/evaluator_class_definer_spec.rb
describe FactoryBot::EvaluatorClassDefiner do it "returns an evaluator when accessing the evaluator class" do evaluator = define_evaluator(parent_class: FactoryBot::Evaluator) expect(evaluator).to be_a(FactoryBot::Evaluator) end it "adds each attribute to the evaluator" do attribute = stub_attribute...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/declaration_list_spec.rb
spec/factory_bot/declaration_list_spec.rb
describe FactoryBot::DeclarationList, "#attributes" do it "returns an AttributeList" do declaration_list = FactoryBot::DeclarationList.new expect(declaration_list.attributes).to be_a(FactoryBot::AttributeList) end it "defines each attribute on the attribute list" do attribute1 = double("attribute 1"...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/factory_spec.rb
spec/factory_bot/factory_spec.rb
describe FactoryBot::Factory do it "has a factory name" do name = :user factory = FactoryBot::Factory.new(name) FactoryBot::Internal.register_factory(factory) expect(factory.name).to eq name end it "has a build class" do name = :user klass = define_class("User") factory = FactoryBot:...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/definition_proxy_spec.rb
spec/factory_bot/definition_proxy_spec.rb
describe FactoryBot::DefinitionProxy, "#add_attribute" do it "declares a dynamic attribute on the factory when the proxy respects attributes" do definition = FactoryBot::Definition.new(:name) proxy = FactoryBot::DefinitionProxy.new(definition) attribute_value = -> { "dynamic attribute" } proxy.add_att...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/strategy_spec.rb
spec/factory_bot/strategy_spec.rb
describe FactoryBot::Strategy do it "returns the class passed when it is instantiated with a class" do strategy = define_class("MyAwesomeClass") result = described_class.lookup_strategy(strategy) expect(result).to eq strategy end it "finds the strategy by name when instantiated with a symbol" do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute_spec.rb
spec/factory_bot/attribute_spec.rb
describe FactoryBot::Attribute do it "converts the name attribute to a symbol" do name = "user" attribute = FactoryBot::Attribute.new(name, false) expect(attribute.name).to eq name.to_sym end it "is not an association" do name = "user" attribute = FactoryBot::Attribute.new(name, false) ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/definition_spec.rb
spec/factory_bot/definition_spec.rb
describe FactoryBot::Definition do it "delegates :declare_attribute to declarations" do definition = described_class.new(:name) expect(definition).to delegate(:declare_attribute).to(:declarations) end it "creates a new attribute list with the name passed when given a name" do name = "great name" ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/sequence_spec.rb
spec/factory_bot/sequence_spec.rb
shared_examples "a sequence" do |options| first_value = options[:first_value] second_value = options[:second_value] it "has a next value equal to its first value" do expect(subject.next).to eq first_value end it "has a next value equal to the 2nd value after being incremented" do subject.next e...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute_assignment_spec.rb
spec/factory_bot/attribute_assignment_spec.rb
describe "Attribute Assignment" do it "sets the <attribute> default value if not overridden" do name = :user define_class("User") { attr_accessor :name, :response } factory = FactoryBot::Factory.new(name) FactoryBot::Internal.register_factory(factory) attr_1 = FactoryBot::Declaration::Dynamic.new...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/aliases_spec.rb
spec/factory_bot/aliases_spec.rb
describe FactoryBot, "aliases" do it "for an attribute should include the original attribute and a version suffixed with '_id'" do aliases = FactoryBot.aliases_for(:test) expect(aliases).to include(:test, :test_id) end it "for a foreign key should include both the suffixed and un-suffixed variants" do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/registry_spec.rb
spec/factory_bot/registry_spec.rb
describe FactoryBot::Registry do it "is an enumerable" do registry = FactoryBot::Registry.new("Great thing") expect(registry).to be_kind_of(Enumerable) end it "finds a registered object" do registry = FactoryBot::Registry.new("Great thing") registered_object = double("registered object") reg...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/callback_spec.rb
spec/factory_bot/callback_spec.rb
describe FactoryBot::Callback do it "has a name" do expect(FactoryBot::Callback.new(:after_create, -> {}).name).to eq :after_create end it "converts strings to symbols" do expect(FactoryBot::Callback.new("after_create", -> {}).name).to eq :after_create end it "runs its block with no parameters" do ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/uri_manager_spec.rb
spec/factory_bot/uri_manager_spec.rb
describe FactoryBot::UriManager do describe ".build_uri" do it "combines the parts to form a Symbol" do expect(described_class.build_uri(:ep1, :ep2, :ep3)) .to eq :"ep1/ep2/ep3" end it "works with a single part" do expect(described_class.build_uri(:ep1)) .to eq :ep1 end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/find_definitions_spec.rb
spec/factory_bot/find_definitions_spec.rb
require "fileutils" shared_examples_for "finds definitions" do before do allow(FactoryBot).to receive(:load) FactoryBot.find_definitions end subject { FactoryBot } end RSpec::Matchers.define :load_definitions_from do |file| match do |given| @has_received = have_received(:load).with(File.expand_pa...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/null_object_spec.rb
spec/factory_bot/null_object_spec.rb
describe FactoryBot::NullObject do it "responds to the given methods" do methods_to_respond_to = %w[id age name admin?] null_object = FactoryBot::NullObject.new(methods_to_respond_to) methods_to_respond_to.each do |method_name| expect(null_object.__send__(method_name)).to be_nil expect(null_o...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute_list_spec.rb
spec/factory_bot/attribute_list_spec.rb
module AttributeList def build_attribute_list(*attributes) FactoryBot::AttributeList.new.tap do |list| attributes.each { |attribute| list.define_attribute(attribute) } end end end describe FactoryBot::AttributeList, "#define_attribute" do it "maintains a list of attributes" do attribute = doubl...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/decorator/attribute_hash_spec.rb
spec/factory_bot/decorator/attribute_hash_spec.rb
describe FactoryBot::Decorator::AttributeHash do describe "#attributes" do it "returns a hash of attributes" do attributes = {attribute_1: :value, attribute_2: :value} component = double(:component, attributes) decorator = described_class.new(component, [:attribute_1, :attribute_2]) expe...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/declaration/association_spec.rb
spec/factory_bot/declaration/association_spec.rb
describe FactoryBot::Declaration::Association do describe "#==" do context "when the attributes are equal" do it "the objects are equal" do declaration = described_class.new(:name, options: true) other_declaration = described_class.new(:name, options: true) expect(declaration).to eq...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/declaration/implicit_spec.rb
spec/factory_bot/declaration/implicit_spec.rb
describe FactoryBot::Declaration::Implicit do context "with a known factory" do it "creates an association attribute" do allow(FactoryBot.factories).to receive(:registered?).and_return true declaration = FactoryBot::Declaration::Implicit.new(:name) attribute = declaration.to_attributes.first ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/declaration/dynamic_spec.rb
spec/factory_bot/declaration/dynamic_spec.rb
describe FactoryBot::Declaration::Dynamic do describe "#==" do context "when the attributes are equal" do it "the objects are equal" do block = -> {} declaration = described_class.new(:name, false, block) other_declaration = described_class.new(:name, false, block) expect(de...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/strategy/build_spec.rb
spec/factory_bot/strategy/build_spec.rb
describe FactoryBot::Strategy::Build do it_should_behave_like "strategy with association support", :create it_should_behave_like "strategy with callbacks", :after_build it_should_behave_like "strategy with strategy: :build", :build end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/strategy/stub_spec.rb
spec/factory_bot/strategy/stub_spec.rb
shared_examples "disabled persistence method" do |method_name| let(:instance) { described_class.new.result(evaluation) } describe "overriding persistence method: ##{method_name}" do it "overrides the method with any arity" do method = instance.method(method_name) expect(method.arity).to eq(-1) ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/strategy/create_spec.rb
spec/factory_bot/strategy/create_spec.rb
describe FactoryBot::Strategy::Create do it_should_behave_like "strategy with association support", :create it_should_behave_like "strategy with callbacks", :after_build, :before_create, :after_create it "runs a custom create block" do evaluation = double( "evaluation", object: nil, notify:...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/strategy/attributes_for_spec.rb
spec/factory_bot/strategy/attributes_for_spec.rb
describe FactoryBot::Strategy::AttributesFor do let(:result) { {name: "John Doe", gender: "Male", admin: false} } let(:evaluation) { double("evaluation", hash: result) } it_should_behave_like "strategy without association support" it "returns the hash from the evaluation" do expect(subject.result(evaluati...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute/association_spec.rb
spec/factory_bot/attribute/association_spec.rb
describe FactoryBot::Attribute::Association do let(:name) { :author } let(:factory) { :user } let(:overrides) { {first_name: "John"} } let(:association) { double("association") } subject { FactoryBot::Attribute::Association.new(name, factory, overrides) } before do # Define an '#association' instance ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute/sequence_spec.rb
spec/factory_bot/attribute/sequence_spec.rb
describe FactoryBot::Attribute::Sequence do let(:sequence_name) { :name } let(:name) { :first_name } let(:sequence) { FactoryBot::Sequence.new(sequence_name, 5) { |n| "Name #{n}" } } subject { FactoryBot::Attribute::Sequence.new(name, sequence_name, false) } before { FactoryBot::Internal.register_sequence(se...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot/attribute/dynamic_spec.rb
spec/factory_bot/attribute/dynamic_spec.rb
describe FactoryBot::Attribute::Dynamic do let(:name) { :first_name } let(:block) { -> {} } subject { FactoryBot::Attribute::Dynamic.new(name, false, block) } its(:name) { should eq name } context "with a block returning a static value" do let(:block) { -> { "value" } } it "returns the value when ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot.rb
lib/factory_bot.rb
require "set" require "active_support" require "active_support/core_ext/module/delegation" require "active_support/core_ext/module/attribute_accessors" require "active_support/deprecation" require "active_support/notifications" require "factory_bot/internal" require "factory_bot/definition_hierarchy" require "factory_...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/reload.rb
lib/factory_bot/reload.rb
module FactoryBot def self.reload Internal.reset_configuration Internal.register_default_strategies find_definitions end end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/callback.rb
lib/factory_bot/callback.rb
module FactoryBot class Callback attr_reader :name def initialize(name, block) @name = name.to_sym @block = block end def run(instance, evaluator) case block.arity when 1, -1, -2 then syntax_runner.instance_exec(instance, &block) when 2 then syntax_runner.instance_exec(...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/syntax.rb
lib/factory_bot/syntax.rb
require "factory_bot/syntax/methods" require "factory_bot/syntax/default" module FactoryBot module Syntax end end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/version.rb
lib/factory_bot/version.rb
module FactoryBot VERSION = "6.5.6".freeze end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/errors.rb
lib/factory_bot/errors.rb
module FactoryBot # Raised when a factory is defined that attempts to instantiate itself. class AssociationDefinitionError < RuntimeError; end # Raised when a trait is defined that references itself. class TraitDefinitionError < RuntimeError; end # Raised when a callback is defined that has an invalid name ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/strategy.rb
lib/factory_bot/strategy.rb
require "factory_bot/strategy/build" require "factory_bot/strategy/create" require "factory_bot/strategy/attributes_for" require "factory_bot/strategy/stub" require "factory_bot/strategy/null" module FactoryBot module Strategy def self.lookup_strategy(name_or_object) return name_or_object if name_or_object...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/definition_hierarchy.rb
lib/factory_bot/definition_hierarchy.rb
module FactoryBot class DefinitionHierarchy delegate :callbacks, :constructor, :to_create, to: Internal def self.build_from_definition(definition) build_to_create(&definition.to_create) build_constructor(&definition.constructor) add_callbacks definition.callbacks end def self.add_c...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/uri_manager.rb
lib/factory_bot/uri_manager.rb
module FactoryBot # @api private class UriManager attr_reader :endpoints, :paths, :uri_list delegate :size, :any?, :empty?, :each?, :include?, :first, to: :@uri_list delegate :build_uri, to: :class # Concatenate the parts, sripping leading/following slashes # and returning a Symbolized String ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/callbacks_observer.rb
lib/factory_bot/callbacks_observer.rb
module FactoryBot # @api private class CallbacksObserver def initialize(callbacks, evaluator) @callbacks = callbacks @evaluator = evaluator @completed = [] end def update(name, result_instance) callbacks_by_name(name).each do |callback| if !completed?(result_instance, ca...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/attribute.rb
lib/factory_bot/attribute.rb
require "factory_bot/attribute/dynamic" require "factory_bot/attribute/association" require "factory_bot/attribute/sequence" module FactoryBot # @api private class Attribute attr_reader :name, :ignored def initialize(name, ignored) @name = name.to_sym @ignored = ignored end def to_pro...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/attribute_list.rb
lib/factory_bot/attribute_list.rb
module FactoryBot # @api private class AttributeList include Enumerable def initialize(name = nil, attributes = []) @name = name @attributes = attributes end def define_attribute(attribute) ensure_attribute_not_self_referencing! attribute ensure_attribute_not_defined! attri...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/factory_runner.rb
lib/factory_bot/factory_runner.rb
module FactoryBot class FactoryRunner def initialize(name, strategy, traits_and_overrides) @name = name @strategy = strategy @overrides = traits_and_overrides.extract_options! @traits = traits_and_overrides end def run(runner_strategy = @strategy, &block) factory = FactoryB...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/registry.rb
lib/factory_bot/registry.rb
require "active_support/hash_with_indifferent_access" module FactoryBot class Registry include Enumerable attr_reader :name def initialize(name) @name = name @items = ActiveSupport::HashWithIndifferentAccess.new end def clear @items.clear end def each(&block) @...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/attribute_assigner.rb
lib/factory_bot/attribute_assigner.rb
module FactoryBot # @api private class AttributeAssigner def initialize(evaluator, build_class, &instance_builder) @build_class = build_class @instance_builder = instance_builder @evaluator = evaluator @attribute_list = evaluator.class.attribute_list @attribute_names_assigned = [] ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/sequence.rb
lib/factory_bot/sequence.rb
require "timeout" module FactoryBot # Sequences are defined using sequence within a FactoryBot.define block. # Sequence values are generated using next. # @api private class Sequence attr_reader :name, :uri_manager, :aliases def self.find(*uri_parts) if uri_parts.empty? fail ArgumentErro...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/evaluator_class_definer.rb
lib/factory_bot/evaluator_class_definer.rb
module FactoryBot # @api private class EvaluatorClassDefiner def initialize(attributes, parent_class) @parent_class = parent_class @attributes = attributes attributes.each do |attribute| evaluator_class.define_attribute(attribute.name, &attribute.to_proc) end end def ev...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/configuration.rb
lib/factory_bot/configuration.rb
module FactoryBot # @api private class Configuration attr_reader( :callback_names, :factories, :inline_sequences, :sequences, :strategies, :traits ) def initialize @factories = Decorator::DisallowsDuplicatesRegistry.new(Registry.new("Factory")) @sequences...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/declaration.rb
lib/factory_bot/declaration.rb
require "factory_bot/declaration/dynamic" require "factory_bot/declaration/association" require "factory_bot/declaration/implicit" module FactoryBot # @api private class Declaration attr_reader :name def initialize(name, ignored = false) @name = name @ignored = ignored end def to_attr...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/linter.rb
lib/factory_bot/linter.rb
module FactoryBot class Linter def initialize(factories, strategy: :create, traits: false, verbose: false) @factories_to_lint = factories @factory_strategy = strategy @traits = traits @verbose = verbose @invalid_factories = calculate_invalid_factories end def lint! if ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/null_factory.rb
lib/factory_bot/null_factory.rb
module FactoryBot # @api private class NullFactory attr_reader :definition def initialize @definition = Definition.new(:null_factory) end delegate :defined_traits, :callbacks, :attributes, :constructor, :to_create, to: :definition def compile end def class_name end ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/decorator.rb
lib/factory_bot/decorator.rb
module FactoryBot class Decorator < BasicObject undef_method :== def initialize(component) @component = component end def method_missing(...) # rubocop:disable Style/MethodMissingSuper @component.send(...) end def send(...) __send__(...) end def respond_to_missing...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/definition.rb
lib/factory_bot/definition.rb
module FactoryBot # @api private class Definition attr_reader :defined_traits, :declarations, :name, :registered_enums, :uri_manager attr_accessor :klass def initialize(name, base_traits = [], **opts) @name = name @uri_manager = opts[:uri_manager] @declarations = DeclarationList.new(n...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/enum.rb
lib/factory_bot/enum.rb
module FactoryBot # @api private class Enum def initialize(attribute_name, values = nil) @attribute_name = attribute_name @values = values end def build_traits(klass) enum_values(klass).map do |trait_name, value| build_trait(trait_name, @attribute_name, value || trait_name) ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/syntax_runner.rb
lib/factory_bot/syntax_runner.rb
module FactoryBot # @api private class SyntaxRunner include Syntax::Methods end end
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/find_definitions.rb
lib/factory_bot/find_definitions.rb
module FactoryBot class << self # An Array of strings specifying locations that should be searched for # factory definitions. By default, factory_bot will attempt to require # "factories.rb", "factories/**/*.rb", "test/factories.rb", # "test/factories/**.rb", "spec/factories.rb", and "spec/factories/*...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/null_object.rb
lib/factory_bot/null_object.rb
module FactoryBot # @api private class NullObject < ::BasicObject def initialize(methods_to_respond_to) @methods_to_respond_to = methods_to_respond_to.map(&:to_s) end def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing if respond_to?(name) nil ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/aliases.rb
lib/factory_bot/aliases.rb
module FactoryBot class << self attr_accessor :aliases end self.aliases = [ [/(.+)_id/, '\1'], [/(.*)/, '\1_id'] ] def self.aliases_for(attribute) aliases.map { |(pattern, replace)| if pattern.match?(attribute) attribute.to_s.sub(pattern, replace).to_sym end }.compact...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/factory.rb
lib/factory_bot/factory.rb
require "active_support/core_ext/hash/keys" require "active_support/inflector" module FactoryBot # @api private class Factory attr_reader :name, :definition def initialize(name, options = {}) assert_valid_options(options) @name = name.respond_to?(:to_sym) ? name.to_sym : name.to_s.underscore.t...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/internal.rb
lib/factory_bot/internal.rb
module FactoryBot # @api private module Internal class << self delegate :after, :before, :callbacks, :constructor, :factories, :initialize_with, :inline_sequences, :sequences, :skip_create, :strategies, :to_create, :tr...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/definition_proxy.rb
lib/factory_bot/definition_proxy.rb
module FactoryBot class DefinitionProxy UNPROXIED_METHODS = %w[ __send__ __id__ nil? send object_id extend instance_eval initialize block_given? raise caller method ].freeze (instance_methods + private_instance_methods).each do |meth...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/trait.rb
lib/factory_bot/trait.rb
module FactoryBot # @api private class Trait attr_reader :name, :uid, :definition delegate :add_callback, :declare_attribute, :to_create, :define_trait, :constructor, :callbacks, :attributes, :klass, :klass=, to: :@definition def initialize(name, **options, &block) @name = name.to_s ...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false
thoughtbot/factory_bot
https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/lib/factory_bot/declaration_list.rb
lib/factory_bot/declaration_list.rb
module FactoryBot # @api private class DeclarationList include Enumerable def initialize(name = nil) @declarations = [] @name = name @overridable = false end def declare_attribute(declaration) delete_declaration(declaration) if overridable? @declarations << declarati...
ruby
MIT
5115775355323252da65f323f6c10b91f2130d48
2026-01-04T15:39:01.421901Z
false