Use with_request_url in component specs

This method is available since view component 2.31.0, and greatly
simplifies tests depending on the current URL.
This commit is contained in:
Javi Martín
2021-08-12 22:50:40 +02:00
parent 474dd09f90
commit 5f19d73b40
4 changed files with 8 additions and 10 deletions

View File

@@ -3,11 +3,10 @@ require "rails_helper"
describe Shared::FilterSelectorComponent, type: :component do
it "renders a form with a select" do
component = Shared::FilterSelectorComponent.new(i18n_namespace: "budgets.investments.index")
allow(component).to receive(:url_for).and_return("/")
allow(component).to receive(:valid_filters).and_return(["unfeasible", "winners"])
allow(component).to receive(:current_filter).and_return(nil)
render_inline component
with_request_url("/") { render_inline component }
expect(page).to have_select "Filtering projects by"
expect(page).to have_selector "form[method='get'].filter-selector select"