One of the Rubocop violations we've got is for lib/amazon_product_api/search_item.rb violating the Naming/PredicateName cop. Basically, it says that when running a method ending in a question mark(a true/false method) that is also named with is, has, etc, that it should have the beginning predicate dropped as it that can be implied. Aka change is_tall? to tall? For us, this means has_valid_image? would turn into valid_image?.
Here's where some of my greenness may be showing: In working to change that method, rspec specifically would throw an undefined method error instead of correctly calling valid_image?. In digging into it, it seems to me that the object being called might not be the same one we were creating in the context step. I've been able to remedy this by switching up our usage of Rspec. It checks the same thing just does it differently. This 'differently' makes sure we're able to specify the exact object we want to test against and makes things happy.
Let me know your thoughts on this. If you're not into it or have another way, let me know. I know using expect is a departure from the repo's wide-spread usage of should, but it solves this case well!
Type of change
Bug fix (non-breaking change which fixes an issue)
Description
One of the Rubocop violations we've got is for
lib/amazon_product_api/search_item.rb
violating theNaming/PredicateName
cop. Basically, it says that when running a method ending in a question mark(a true/false method) that is also named with is, has, etc, that it should have the beginning predicate dropped as it that can be implied. Aka changeis_tall?
totall?
For us, this meanshas_valid_image?
would turn intovalid_image?
.Here's where some of my greenness may be showing: In working to change that method, rspec specifically would throw an undefined method error instead of correctly calling
valid_image?
. In digging into it, it seems to me that the object being called might not be the same one we were creating in the context step. I've been able to remedy this by switching up our usage of Rspec. It checks the same thing just does it differently. This 'differently' makes sure we're able to specify the exact object we want to test against and makes things happy.Let me know your thoughts on this. If you're not into it or have another way, let me know. I know using
expect
is a departure from the repo's wide-spread usage ofshould
, but it solves this case well!Type of change
How Has This Been Tested?
bundle exec rake
passes: ✅