Skip to content

assert_api_conform method does not perform actual assertions, causing a warning for Rails >= 7.2 #312

@schwarzfa

Description

@schwarzfa

Description

The provided assert_api_conform method does not perform actual assertions using Rails' testing framework. As a result, when this method is used in Rails tests, Rails emits a warning indicating that the test case does not perform any assertions.

Before Rails 7.2 you could configure Rails to ignore or only log such warnings (:ignore being the default):

config.active_support.assertionless_tests_behavior = :ignore
config.active_support.assertionless_tests_behavior = :log

With Rails 7.2, the ActiveSupport::TestCase emits warnings when tests are executed without any assertions, with no more way to configure the behavior.

Steps to Reproduce

  1. Set Up a Rails Test Case in a Rails app with version >= 7.2
require 'test_helper'

class ApiConformanceTest < ActiveSupport::TestCase
  test "API response conforms to specification" do
    get '/api/endpoint'
    assert_api_conform(status: 200)
  end
end
  1. Run the Tests:
rails test
  1. Observe the Warning:
Test is missing assertions: `test_API_response_conforms_to_specification` /path/to/test

Thank you for having a look and maintaining this great gem :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions