Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around for rspec-mocks#1460 issue with expectations on kwargs #2618

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ RSpec/SubjectStub:
- 'spec/lib/blacklight/search_state_spec.rb'
- 'spec/models/blacklight/document/cache_key_spec.rb'
- 'spec/models/blacklight/search_builder_spec.rb'
- spec/presenters/blacklight/document_presenter_spec.rb
- 'spec/services/blacklight/search_service_spec.rb'

# Offense count: 75
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

it 'renders an action link' do
if Rails.version >= '6'
allow(view_context).to receive(:some_tool_solr_document_path).with(document, only_path: true).and_return('/asdf')
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
else
allow(view_context).to receive(:some_tool_solr_document_path).with(document).and_return('/asdf')
end
Expand Down
6 changes: 3 additions & 3 deletions spec/helpers/blacklight/url_helper_behavior_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

it "calls url_for on the engine scope" do
expect(my_engine).to receive(:url_for)
.with(q: "query", f: "facets", controller: "catalog")
.with({ q: "query", f: "facets", controller: "catalog" })
.and_return('link-url')
expect(tag).to match /Back to Search/
expect(tag).to match /link-url/
Expand Down Expand Up @@ -170,12 +170,12 @@
let(:document) { SolrDocument.new(id: 1) }

it "determines the correct route for the document class" do
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
allow(helper.main_app).to receive(:track_test_path).with({ id: have_attributes(id: 1) }).and_return('x')
expect(helper.session_tracking_path(document)).to eq 'x'
end

it "passes through tracking parameters" do
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
allow(helper.main_app).to receive(:track_test_path).with({ id: have_attributes(id: 1), x: 1 }).and_return('x')
expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
end

Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/blacklight_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
end

it "sends parameters" do
expect(presenter).to receive(:link_rel_alternates).with(unique: true).and_return(result)
expect(presenter).to receive(:link_rel_alternates).with({ unique: true }).and_return(result)
expect(helper.render_link_rel_alternates(document, unique: true)).to eq result
end
end
Expand Down Expand Up @@ -169,7 +169,7 @@
describe "#render_document_index" do
it "renders the document index with the current view type" do
allow(helper).to receive_messages(document_index_view_type: :current_view)
allow(helper).to receive(:render_document_index_with_view).with(:current_view, [], a: 1, b: 2)
allow(helper).to receive(:render_document_index_with_view).with(:current_view, [], { a: 1, b: 2 })
helper.render_document_index [], a: 1, b: 2
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/blacklight/facet_item_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

it 'is the url to apply the facet' do
allow(search_state).to receive(:add_facet_params_and_redirect).with('key', facet_item).and_return(f: 'x')
allow(view_context).to receive(:search_action_path).with(f: 'x').and_return('/catalog?f=x')
allow(view_context).to receive(:search_action_path).with({ f: 'x' }).and_return('/catalog?f=x')

expect(presenter.href).to eq '/catalog?f=x'
end
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/blacklight/field_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def render

context 'when field has link_to_facet with true' do
before do
allow(request_context).to receive(:search_action_path).with('f' => { 'link_to_facet_true' => ['x'] }).and_return('/foo')
allow(request_context).to receive(:search_action_path).with({ 'f' => { 'link_to_facet_true' => ['x'] } }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
end

Expand All @@ -91,7 +91,7 @@ def render

context 'when field has link_to_facet with a field name' do
before do
allow(request_context).to receive(:search_action_path).with('f' => { 'some_field' => ['x'] }).and_return('/foo')
allow(request_context).to receive(:search_action_path).with({ 'f' => { 'some_field' => ['x'] } }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
end

Expand Down