instance method
assert_initializer
Ruby on Rails 7.2.3
Since v7.2.3Signature
assert_initializer(name, *contents, &block)
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
Parameters
-
namereq -
contentsrest -
blockblock
Source
# File railties/lib/rails/generators/testing/assertions.rb, line 141
def assert_initializer(name, *contents, &block)
assert_file("config/initializers/#{name}", *contents, &block)
end
Defined in railties/lib/rails/generators/testing/assertions.rb line 141
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Generators::Testing::Assertions