Method: Ndd::RSpec::Rails::Matchers::Model#have_a_translated_model

Defined in:
lib/ndd/rspec/rails/matchers/model.rb

#have_a_translated_modelNdd::RSpec::Rails::Matchers::Model::HaveATranslatedModel

Ensure that a model has an associated translation.

More precisely, ensure that

I18n.t(locale, "activerecord.models.{snake_case_class_name}")

returns a value for the default locale (i.e. I18n.default_locale) or all the available locales (i.e. I18n.available_locales).

Examples:


RSpec.describe MyModel, type: :model do
  # both are equivalent
  it { is_expected.to have_a_translated_model }
  it { is_expected.to have_a_translated_model.in_available_locales }

  it { is_expected.to have_a_translated_model.in_default_locale }
end

90
91
92
# File 'lib/ndd/rspec/rails/matchers/model.rb', line 90

def have_a_translated_model # rubocop:disable Style/PredicateName
  HaveATranslatedModel.new
end