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

validate_aspect_ratio_of show wrong number of arguments (given 1, expected 2) #246

Open
sbrocos opened this issue Apr 3, 2024 · 2 comments

Comments

@sbrocos
Copy link

sbrocos commented Apr 3, 2024

I have define this in mi model:

  validates :cover, attached: true,
                    content_type: %i[png jpeg],
                    aspect_ratio: :square,
                    dimension: { width: { min: 400, max: 1200 } }

And in the Rspec
it { is_expected.to validate_aspect_ratio_of(:cover).allowing(:square) }

and obtain this the execute the test:
Captura de pantalla 2024-04-03 a las 16 33 14

I show the code, and I don't understand what it's the problem with this validation.

Thanks for your work

@osmarluz
Copy link

osmarluz commented Apr 4, 2024

@sbrocos there's an issue with the initialization of the matcher class ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher. As a workaround you can do this:

it { is_expected.to ActiveStorageValidations::Matchers::AspectRatioValidatorMatcher.new(:cover).allowing(:square) }

Hope this helps! o/

@Mth0158
Copy link
Collaborator

Mth0158 commented Apr 4, 2024

Hi @sbrocos,
I'll have a look at it, seems like an easy bug to fix.

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

No branches or pull requests

3 participants