diff --git a/docs/api.md b/docs/api.md index fc3c916ef..b2b3f3304 100644 --- a/docs/api.md +++ b/docs/api.md @@ -349,6 +349,14 @@ with_request_url("/users/42") do end ``` +To use a specific host, pass the host param: + +```ruby +with_request_url("/users/42", host: "app.example.com") do + render_inline(MyComponent.new) +end +``` + ### `#with_variant(variant)` Set the Action Pack request variant for the given block: diff --git a/lib/view_component/test_helpers.rb b/lib/view_component/test_helpers.rb index a3989e026..cbea3301a 100644 --- a/lib/view_component/test_helpers.rb +++ b/lib/view_component/test_helpers.rb @@ -155,6 +155,14 @@ def with_controller_class(klass) # end # ``` # + # To use a specific host, pass the host param: + # + # ```ruby + # with_request_url("/users/42", host: "app.example.com") do + # render_inline(MyComponent.new) + # end + # ``` + # # @param path [String] The path to set for the current request. # @param host [String] The host to set for the current request. def with_request_url(path, host: nil)