uclibs / ucrate

Scholar@UC: University of Cincinnati's self-submission institutional repository
https://scholar.uc.edu
Other
5 stars 3 forks source link

1082 - Remove stub chain #1095

Closed Janell-Huyck closed 8 months ago

Janell-Huyck commented 9 months ago

Fixes #1082

_Removes old stubchain methods

Summary

This PR refactors the test suites for _user_util_links.html.erb_spec.rb and _index_list_default.html.erb_spec.rb to remove the deprecated stub_chain methods. The code now relies on cleaner, up-to-date RSpec syntax, and is more maintainable as a result.

Details

How the stub_chain is handled:

Helper method for setting up a mock for current_ability
def stub_current_ability(return_value)
  current_ability = double('CurrentAbility')
  allow(view).to receive(:current_ability).and_return(current_ability)
  allow(current_ability).to receive(:can_create_any_work?).and_return(return_value)
end
Usage inside the before block
stub_current_ability(true)

Why "allow" Over "expect"

We opted to use allow instead of expect because these stubs were set up in before-do blocks and are not the primary behavior under test. By using allow, we can establish the necessary background for the actual tests without enforcing strict expectations on the messages received by our doubles, making the tests less brittle and more focused on what we are actually interested in testing.

Additional changes