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

Wrong touches Class for STI test #1388

Open
helmiItsavirus opened this issue Dec 24, 2020 · 3 comments
Open

Wrong touches Class for STI test #1388

helmiItsavirus opened this issue Dec 24, 2020 · 3 comments

Comments

@helmiItsavirus
Copy link

helmiItsavirus commented Dec 24, 2020

I found an issue when I use the STI model on my apps

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

class ContentSource < ApplicationRecord
end

class Facebook < ContentSource
end

RSpec.describe Facebook, type: :model do
  it { should_not allow_values("https://facebook.com/admin").for(:url) }
end

expected the ContentSource to be invalid, but it was valid instead

The Rspec touch ContentSource instead of Facebook class, how it could be? or do I need to configure something?

@vsppedro
Copy link
Collaborator

vsppedro commented Dec 28, 2020

Hi, @helmiItsavirus, thank you for opening this issue. It seems to me that we probably have a bug with this matcher.

For now, I'll add the label Need to investigate, and as soon I have the time I'll take a look.

#1381 - saving for future references, probably the same problem.

@mcmire
Copy link
Collaborator

mcmire commented Dec 28, 2020

@helmiItsavirus I'm having trouble understanding why this is happening given your example. I cleaned up the formatting of your code so it's easier to read, but in your example both of your ContentSource and Facebook classes inherit from ApplicationRecord. You say that this involves STI, but neither of those are using STI. Are you sure that's accurate?

@helmiItsavirus
Copy link
Author

helmiItsavirus commented Dec 30, 2020

@mcmire The example has been updated, sorry for my mistake, Facebook should inherent to ContentSource

The error message still touches ContentSource instead of Facebook. In my perception, Rspec should test subclass that I am defined

If you have time, you can try to create a spec using an STI model similar to mine, I guess the problem will happen to you as well

@helmiItsavirus helmiItsavirus changed the title Wrong touch Class for STI test Wrong touches Class for STI test Dec 30, 2020
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

3 participants