Last active
November 8, 2017 11:19
-
-
Save krisleech/264737080e6e6de4ae491a9044d01465 to your computer and use it in GitHub Desktop.
Trying to reproduce bug in FactoryBot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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