Setting created_at or updated_at on a fixture definition raises NoMethodError:
FixtureBot.define do
user :john do
created_at '<%= 7.months.ago %>'
end
end
NoMethodError: undefined method 'created_at' for #<FixtureBot::Row::Definition:0x000000012e820328>
created_at '<%= 7.months.ago %>'
^^^^^^^^^^
This also affects updated_at:
FixtureBot.define do
user :john do
updated_at '<%= 7.months.ago %>'
end
end
Use case
Many test scenarios require fixtures with specific timestamps. For example:
- Scoping by created_at: A test for "users created more than 6 months ago" needs created_at: <%= 7.months.ago %>
- Time-window queries: Event fixtures need specific created_at to fall inside or outside a date range
Standard Rails YAML fixtures support this without issue:
# test/fixtures/users.yml
john:
created_at: <%= 7.months.ago %>
FixtureBot should be able to express the same thing.
Setting
created_atorupdated_aton a fixture definition raises NoMethodError:This also affects updated_at:
Use case
Many test scenarios require fixtures with specific timestamps. For example:
Standard Rails YAML fixtures support this without issue:
FixtureBot should be able to express the same thing.