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

Using filter NPLUSONE_FILTER in rspec returns always success result #54

Open
dmitriy-borowskiy opened this issue May 7, 2022 · 1 comment
Assignees

Comments

@dmitriy-borowskiy
Copy link

dmitriy-borowskiy commented May 7, 2022

What did you do?

I have a following scenario

context "N+1", :n_plus_one do
      it "n+1" do
        audit_type_2 = create(:audit_type, account: org)
        audit_type_3 = create(:audit_type, account: org)
        audit_type_4 = create(:audit_type, account: another_org)


        expect { do_request(:get, "/api/v3/project_types?org_id=#{org.organization_id}", org_user) }.to perform_constant_number_of_queries
      end
    end

command running test

bundle exec rspec spec/controllers/api/v3/audit_types_controller_spec.rb:338

Failure/Error: expect { do_request(:get, "/api/v3/project_types?org_id=#{org.organization_id}", org_user) }.to perform_constant_number_of_queries
     
       Expected to make the same number of queries, but got:
         194 for N=2
         195 for N=3
       Unmatched query numbers by tables:
     # ./spec/controllers/api/v3/audit_types_controller_spec.rb:345:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:83:in

If I try to run test with filter, tests result returns success, but should return failure:

NPLUSONE_VERBOSE=1 NPLUSONE_FILTER=accounts bundle exec rspec spec/controllers/api/v3/audit_types_controller_spec.rb:338

returns: 200 with only specified fields

Finished in 2.42 seconds (files took 6.66 seconds to load)
1 example, 0 failures

What did you expect to happen?

Unmatched query numbers by tables:
accounts (SELECT)

@palkan
Copy link
Owner

palkan commented May 24, 2022

Hey!

Could you please show the output when running with the only NPLUSONE_VERBOSE=1 env var? (w/o filtering) I wonder, which queries have been collected (and why we filtered them all out).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants