diff --git a/lib/faker/default/html.rb b/lib/faker/default/html.rb
index bf94c2b1d9..2630b277ef 100644
--- a/lib/faker/default/html.rb
+++ b/lib/faker/default/html.rb
@@ -220,7 +220,7 @@ def available_methods
def generate_table_row(tag, cell_count)
row = "
\n"
cell_count.times do
- row += "<#{tag == 'th' ? 'th' : 'td'}>#{Lorem.word}#{tag == 'th' ? 'th' : 'td'}>\n"
+ row += "<#{tag == 'th' ? 'th' : 'td'}>#{Faker::Lorem.word}#{tag == 'th' ? 'th' : 'td'}>\n"
end
row += "
\n"
row
diff --git a/test/faker/default/test_faker_html.rb b/test/faker/default/test_faker_html.rb
index 69235a03ed..bfd5af5fb7 100644
--- a/test/faker/default/test_faker_html.rb
+++ b/test/faker/default/test_faker_html.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require 'open3'
+require 'rbconfig'
require_relative '../../test_helper'
class TestFakerHTML < Test::Unit::TestCase
@@ -51,6 +53,22 @@ def test_table
assert_equal(12, count_occurrences(table_html, ''))
end
+ def test_table_with_lazy_loading
+ # A fresh process ensures another generator has not already loaded Lorem.
+ code = <<~RUBY
+ require 'faker'
+ abort 'Lorem was already loaded' if Faker.const_defined?(:Lorem, false)
+ puts Faker::HTML.table
+ RUBY
+ lib_dir = File.expand_path('../../../lib', __dir__)
+ output, status = Open3.capture2e({ 'FAKER_LAZY_LOAD' => '1' }, RbConfig.ruby, "-I#{lib_dir}", '-e', code)
+
+ assert_predicate status, :success?, output
+ assert_equal 3, count_occurrences(output, ' | ')
+ assert_equal 12, count_occurrences(output, ' | ')
+ assert_equal 5, count_occurrences(output, ' | ')
+ end
+
def test_script
assert_match(/