tabletop-companion/test/test_helper.rb

26 lines
701 B
Ruby

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
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
def attr_name(klass, attr)
klass.human_attribute_name(attr)
end
end
end