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

RSpec/Rails/HaveHttpStatus autofix broke test suite #1823

Closed
VitaliySerov opened this issue Mar 1, 2024 · 6 comments · Fixed by #1824
Closed

RSpec/Rails/HaveHttpStatus autofix broke test suite #1823

VitaliySerov opened this issue Mar 1, 2024 · 6 comments · Fixed by #1824
Labels

Comments

@VitaliySerov
Copy link

Hey guys I have a sinatra application:

https://github.com/ONLYOFFICE-QA/sinatra-post-to-redis

some specs in it looks like this:

it 'allows send post notification' do
    post '/', notification: 'hello rspec'

    expect(last_response.status).to eq 200
  end

after upgrading rubocop-rspec and applying auto-update expect line was changes to expect(last_response).to have_http_status :ok

And this changes execution of rspec tests, seems that sinatra apps are not aware of those:

  1) SinatraPostToRedis allows send post notification
     Failure/Error: expect(last_response).to have_http_status :ok
       expected #<Rack::MockResponse:0x00007f68ae7fea68 @original_headers={"Content-Type"=>"text/html;charset=utf-8",....0/gems/rack-2.2.8.1/lib/rack/response.rb:287>, @block=nil, @body=["OK"], @buffered=true, @length=2> to respond to `has_http_status?`
     # ./spec/sinatra_post_to_redis/sinatra_post_to_redis_spec.rb:10:in `block (2 levels) in <top (required)>'

You can see changes here:

ONLYOFFICE-QA/sinatra-post-to-redis@5eb9d7f

@ydah
Copy link
Member

ydah commented Mar 1, 2024

@VitaliySerov Thank you for reporting. As the name implies, it's a cop in the Rails department, so we recommend departmental disable in .rubocop.yml as follows. How about setting?

RSpec/Rails:
  Enabled: false

@VitaliySerov
Copy link
Author

VitaliySerov commented Mar 1, 2024

Yeah, of course, I can disable it

But maybe there should be some fail-safe mechanism in rubocop-rspec so that non-rails applications will not be detected by Rspec/Rails cop?

If it's not possible - I think there should be a line in the readme "please disable Rspec/Rails in case you use rubocop-rspec in non-rails env`

@ydah
Copy link
Member

ydah commented Mar 1, 2024

Soon, the RSpec/Rails cop will be cut off to another gem. Users will be able to hire only the departments they need.

@VitaliySerov
Copy link
Author

@ydah All right, seems like a good solution, but I think we can keep my issue opened until the migration is done?

@ydah
Copy link
Member

ydah commented Mar 1, 2024

If this is a good solution, I think this issue can be closed because it overlaps with the following issue.

@VitaliySerov
Copy link
Author

Ok, will close it

Thanks for your work :)

ydah added a commit that referenced this issue Mar 1, 2024
@ydah ydah mentioned this issue Mar 1, 2024
4 tasks
ydah added a commit that referenced this issue Mar 1, 2024
ydah added a commit to rubocop/rubocop-rspec_rails that referenced this issue Mar 27, 2024
ydah added a commit to rubocop/rubocop-rspec_rails that referenced this issue Mar 27, 2024
@ydah ydah added the bug label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants