Forg/test/test_helper.rb

22 lines
622 B
Ruby
Raw Normal View History

2024-04-13 10:22:40 +00:00
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
module ActiveSupport
class TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
2024-04-14 10:10:10 +00:00
def assert_must_exist(record, field)
assert record.valid?
record.attributes = { "#{field}": nil }
assert_not record.valid?
assert_includes record.errors[field.to_sym], "can't be blank"
assert_raises { record.save(validate: false) }
end
2024-04-13 10:22:40 +00:00
end
end