Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

be_unprocessable_entity matcher not working with rack 3.1.x #1464

@Aqualon

Description

@Aqualon

Subject of the issue

Not sure where this fits, but I have an issue in a controller spec that should verify a 422 response.

it 'returns 422' do
  post :create, params: share_params
  expect(response).to be_unprocessable_entity
end

With rack 3.0.11 this works fine and via byebug found out that be_unprocessable_entity comes from rspec-expecations DSL

(byebug) be_unprocessable_entity
#<RSpec::Matchers::DSL::Matcher be_unprocessable_entity>
(byebug) method(:be_unprocessable_entity).source_location
["/Users/bruno.escherl/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/dsl.rb", 75]

Updating to rack 3.1.3 I get this error

Failure/Error: expect(response).to be_unprocessable_entity
       expected #<ActionDispatch::TestResponse:0x000000013573d530 @mon_data=#<Monitor:0x0000000135af03d0>, @mon_data_...equest POST "http://test.host/rest/activities/legacy/users/2322146568/activities.json" for 0.0.0.0>> to respond to `unprocessable_entity?

and checked again and this time get

(byebug) be_unprocessable_entity
#<RSpec::Matchers::BuiltIn::BePredicate:0x00000001317d6130 @method_name=:be_unprocessable_entity, @args=[], @block=nil>
(byebug) method(:be_unprocessable_entity).source_location
nil

So somehow updating rack causes be_unprocessable_entity to be something different?

I can change the expectation to expect(response).to be_unprocessable which still works, but would be curious what is up there?

Your environment

  • Ruby version: 3.3.3
  • rspec-expectations version: 3.13.1
  • rails: 7.1.3.4

Steps to reproduce

Expected behavior

Actual behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions