tests: add respond_to_search test helper.

Add a `respond_to_search` test helper for concisely testing that a
controller's index action correctly responds to a search. Usage:

    # Tests that `/tags.json?search[name]=touhou` returns the `touhou` tag.

    setup { @touhou = create(:tag, name: "touhou") }
    should respond_to_search(name: "touhou").with { @touhou }
This commit is contained in:
evazion
2020-06-23 23:32:14 -05:00
parent d71f3cbac1
commit 2b969646bc
2 changed files with 49 additions and 0 deletions

View File

@@ -61,6 +61,8 @@ class ActiveSupport::TestCase
end
class ActionDispatch::IntegrationTest
extend ControllerHelper
register_encoder :xml, response_parser: ->(body) { Nokogiri.XML(body) }
def method_authenticated(method_name, url, user, **options)