[go: up one dir, main page]

Defining Fabricators: Attributes Not Passed to Blocks When Fabricator Inherrits

Using 2.28:

Fabricator(:user) do
  email { sequence(:email) { |i| "user#{i}@example.com" } }
  password { Devise.friendly_token.first(Devise.password_length.end) }
end

Fabricator(:anonymous_user, :from => :user) do
  last_sign_in_ip { "127.0.0.1" }
  email { |attrs| p attrs; "127.0.0.1@anonymous.example.com" }
end

In the above code attrs is {}. In :user this is not a problem. I assume it's due to :from.