-
Notifications
You must be signed in to change notification settings - Fork 114
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
Extract option logic from Grover class #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I could go either way on extending
Hash
. Fine how it is though. OptionsFixer.new...run
looks fine. It's only an internal class so not too bothered- That's odd.. must be something different about the
MiniMagick
install on your machine?! I've tested it on Linux and Mac and not come across that before. In any case, easy fix will be to modify themean_colour_statistics
method ~L578 in thespec/grover_spec.rb
file to something like:
def mean_colour_statistics(image)
%w[red green blue].map { |colour| image.data.dig('channelStatistics', colour, 'mean').to_s }
end
(i.e. convert the mean colour coming from the image data hash into a string).
Weird!
👍 I was thinking the same thing. Thanks for confirming. I'll add it to the PR. ...and Code Climate is at it again 😬 https://codeclimate.com/github/Studiosity/grover/pull/46 But I was actually thinking of making a helper for all the fix_xx_options! methods that took an array of options and a transformation method/block. Maybe I'll look into that and see if that makes Code Climate happy. |
I commented about that: #46 (comment) |
It actually turned out to be a change in ImageMagick (I geeked out and dug through the source) ImageMagick/ImageMagick@bc978e0#diff-b911bfc2e4a717df4fc996ef7decb2ffL713-R716 |
This fixes expected: ["165", "42", "42"] got: [165, 42, 42] spec errors caused be a change in ImageMagick. See ImageMagick/ImageMagick@bc978e0#diff-b911bfc2e4a717df4fc996ef7decb2ffL713-R716
Edit: Nevermind. I get it now. It converts strings that contains arrays into arrays. Can you clarify what this does? Lines 322 to 326 in d455f75
From what I can see Example: Line 275 in d455f75
So |
FYI this spec is failing on my machine Lines 115 to 119 in d455f75
It's using the expectation in the first branch. But on my system, I have I'm running MacOS Catalina 10.15.3 with ImageMagick:
I can ignore for now. May be due to the newer version of ImageMagick on my system? |
Also FYI this spec is failing. Lines 313 to 317 in d455f75
With
And this spec is failing Line 395 in d455f75
With
These failures are on |
2c52623
to
ee94464
Compare
Please hold off on merge until I add a few specs... |
Correct. It allows the |
Right. Puppeteer have been moving towards making the library driver agnostic and it looks like they've released a new version that does that (along with some changes to the error message copy). Best solution is likely going to be to make the copy match a regex to allow for
I've never been a fan of the method used here, but it was a lot more reliable than pixel testing. It appears to be passing in Travis.. no doubt slightly different versions of the ImageMagick toolset etc |
I added fix for this. See 0d1b1c9
I added a variant to fix the spec on my system See 3d10ae5. Feel free to pull if this isn't a direction you want to go. |
68593e5
to
3d10ae5
Compare
This is ready for another review. We might want to keep 561127f un-squashed to document that change. I'm happy to rebase to keep the commits we want and squash everything else. |
Had some insight overnight. I'm adding some specs for |
dfa1767
to
6106856
Compare
With the addition of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change is looking really good @willkoehler 👍
I've noticed a few things that I think should be addressed before merging though. Please see comments below.
I'm not too bothered either way. It's a pretty trivial fix and only relates to the specs so not sure it really needs much documenting |
Not sure I following your meaning here? The image/PDF reader dependencies are necessary to validate the conversion process is doing what it's supposed to. How would this change eliminate that need? |
I though some of those specs may have just been checking that parameters were parsed and combined correctly. (Just a guess on my part since I don't have much context.) But if they are validating the conversion process, I agree, it wouldn't make sense to change them. |
Good point. We should just squash it in. |
I fixed the last remaining broken spec on my system: c4abfb4 |
c4abfb4
to
30c5cb8
Compare
The failure is a flickering spec: https://travis-ci.org/Studiosity/grover/jobs/655011626. Is there a way I can re-run these? 👇 |
No, but I can :) I'm thinking I might add https://github.com/NoRedInk/rspec-retry at some point to help with the flake. It's often an issue with puppeteer just not booting. Bit odd.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @willkoehler, looks great! 👍
Awesome 🙌 Let me know if anything else comes up that I can help with. It's a pleasure working with you. |
Great, thanks @willkoehler. I can't think of any pressing changes needed at the moment. I'm currently updating the OptionsFixer to include some more of the missing type casting (some viewport options and some screenshot options). There are plenty of things that Puppeteer can do that Grover doesn't support, but to be honest I'm not sure the merits of going all in on trying to get full API support. |
@abrom I'm pushing up a WIP to get your feedback on the general shape of the solution. If it looks ok, I'll refine and add some specs.
More specifically
OptionsBuilder
fromHash
? Too "tricky"? I could also just return theoptions
hash from an accessor method or something.OptionsFixer.new
i.e. doesOptionsFixer.new(options).run
look like a reasonable API?expected: ["165", "42", "42"] got: [165, 42, 42]
on my system (/spec/grover_spec.rb:424) which is making it hard to know if I broke anything. These specs are failing even on theRelease v0.10.1
commit so I don't think they're caused by my changes. But I don't remember seeing these failures before on my system so that's kind of 🤔