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

Capybara fuzzy matching #22

Closed
zberkom opened this issue Jul 22, 2015 · 16 comments
Closed

Capybara fuzzy matching #22

zberkom opened this issue Jul 22, 2015 · 16 comments

Comments

@zberkom
Copy link

zberkom commented Jul 22, 2015

There are examples of how to do fuzzy matching in Bacon and Frank, but I can't figure out how to do it for a rails app using capybara.

I tried expect(page).to look_like("Profile", 15) with no success. Any help would be much appreciated

Thanks!

@squidpunch
Copy link

does expect(page).to look_like("Profile", fuzz_factor: 15) work?

Checking the rspec tests that looks like the syntax you are looking for - let me know!

@zberkom
Copy link
Author

zberkom commented Jul 22, 2015

Just tried it and unfortunately its still failing with a very minor differences between the two screen shots. Any other ideas.

@squidpunch
Copy link

I'd try a higher percent. passing in 100 will make an image pass if they are the same size but completely different. so 15% differential may still be below the change threshold you are looking at. I remember discussing the fuzz factor at the #inspect conference, and I believe people were talking about using 85% or so for the fuzz factor, so that the clock on an iphone didnt fail - not sure if thats too much and then will loose the things you are going to test...but my gut says play with this number and see if it impacts your test. Go with 100, make sure that passes, then go down from there 👍

If you have a sample repo I could give it a look too, I've never used juxtapose with a rails app, so I am just throwing out ideas but I bet we can track it down. If i have time later this evening or tomorrow morning Ill throw together a quick app to see if i can reproduce this (assuming you dont have a public repo I can just clone)

@jamonholmgren
Copy link

I usually use 4% on RubyMotion iOS.

@squidpunch
Copy link

...so i was totally wrong on the percent, I was going to tag you @jamonholmgren for clarity :)

@jamonholmgren
Copy link

I watch this repo, so I saw it. :)

@zberkom
Copy link
Author

zberkom commented Jul 24, 2015

Looked through the source code and can't find a way around this:
image

Is fuzz_factor included for capybara specs?

@squidpunch
Copy link

I'll dig around. Or maybe @thegreatape can answer quicker! :)

@zberkom
Copy link
Author

zberkom commented Jul 24, 2015

@squidpunch Thanks!

@squidpunch
Copy link

@zberkom pretty sure fuzz_factor isnt setup in rails
https://github.com/terriblelabs/motion-juxtapose/blob/master/lib/juxtapose/rspec.rb#L4-L5

want to throw together a PR for it? I can do it probably sometime after the weekend but I'd gladly review one if you want to work it out before then :)

@squidpunch
Copy link

@zberkom pretty sure I have a working fix put together for you. I just want to have @thegreatape review the PR before we merge/release!

you could test this out locally if you wanted by updating your gemfile as the following....

gem "motion-juxtapose", github: "squidpunch/motion-juxtapose", branch: "working-with-rails-matcher"

it would be great to let me know if that fixes your problem - my quick sample app seemed to allow me to use the fuzz factor, but like I said before, I had never used this gem in rails previously.

@squidpunch
Copy link

once its merged and released, you can go back to the rubygems released version - but it would be great to verify this is a working fix on your project as well, and I am not overlooking something.

@zberkom
Copy link
Author

zberkom commented Jul 27, 2015

@squidpunch fuzz_factor seems to be working, but only if I put it at 80-90, otherwise it still throws errors for minor differences. Btw. thanks for looking into this for me!

@squidpunch
Copy link

@zberkom I'll change up this PR to not include the require stuff, and get this merged. Thanks for reporting it - as far as the percentage you need to use....this is simply being passed down to imagemagick on how they handle the fuzz. I wouldnt expect it to be so high, but at least you have a way to get it working, and maybe there is a way to enhance fuzz a bit more in a future change if someone has time to dive a bit more into how imagemagick actually works :)

@squidpunch
Copy link

@zberkom releasing momentarily!

@zberkom
Copy link
Author

zberkom commented Jul 27, 2015

@squidpunch Great, thanks!

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