method

assert_initializer

rails latest stable - Class: Rails::Generators::Testing::Assertions

Method not available on this version

This method is only available on newer versions. The first available version (v7.2.3) is shown here.

assert_initializer(name, *contents, &block)
public

Asserts a given initializer exists. You need to supply a path relative to the `config/initializers/` directory.

assert_initializer "mail_interceptors.rb"

You can also give extra arguments. If the argument is a regexp, it will check if the regular expression matches the given file content. If it’s a string, it compares the file with the given string:

assert_initializer "mail_interceptors.rb", /SandboxEmailInterceptor/

Finally, when a block is given, it yields the file content:

assert_initializer "mail_interceptors.rb" do |initializer|
  assert_match(/SandboxEmailInterceptor/, initializer)
end