Skip to content

Instantly share code, notes, and snippets.

@krisleech
Last active November 8, 2017 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisleech/264737080e6e6de4ae491a9044d01465 to your computer and use it in GitHub Desktop.
Save krisleech/264737080e6e6de4ae491a9044d01465 to your computer and use it in GitHub Desktop.
Trying to reproduce bug in FactoryBot
require 'active_record'
require 'factory_bot'
require 'pry'
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3',
:database => File.dirname(__FILE__) + "/db.sqlite3")
ActiveRecord::Schema.define do
self.verbose = false
create_table :users, :force => true do |t|
t.string :username
t.timestamps
end
end
class User < ActiveRecord::Base; end
FactoryBot.define do
factory :user do
end
end
username = 'foo'
user = FactoryBot.create(:user, username: username)
username.frozen? # => false (but is true in production code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment