Comments (4)
Yes, should is not part of Hashdiff, it's from the gem RSpec. Normally
there's no need to use "diff.should" except in tests.
2014-11-06 10:41 GMT+01:00 wimrijnders [email protected]:
Hi there,
I'm a bit confused. I'm following the QuickStart, which says to compare in
the following way (eg.):diff = HashDiff.diff(a, b)
diff.should == [['-', 'a', 3], ['-', 'b', 2]]However, variable diff is set to a standard array type and does not have a
method 'should'. Am I missing something? Or did the specs change in the
meantime?I'm using ruby v 1.9.2. My intention is two compare two complex hash to
see if they're identical. So in the code above, I just want to check if
diff.should == [].Thanks,
Wim.
β
Reply to this email directly or view it on GitHub
#10.
from hashdiff.
Thanks for the quick answer! It confused me a bit, I hope you understand. Perhaps it's possible to adjust the documentation?
So this should be ok, right?
# Test if two hashes have exactly the same content
diff = HashDiff.diff(a, b)
diff.empty?
Will this also work if one of the values happens to be nil?
Perhaps there is a more efficient way of doing this? Eg. a method that returns as soon as a difference is encountered?
Thanks in advance.
from hashdiff.
Indeed the documentation can be improved a bit to avoid confusion.
from hashdiff.
Thank you for your response. Using diff.empty? appears to work as expected.
I trust you will make a note for updating the documentation. For the rest, I regard this as a non-issue and hereby close it.
Thank you for your time!
from hashdiff.
Related Issues (20)
- Ruby 1.8.7 compatibility HOT 2
- make use_lcs: false the default HOT 2
- RexEx in compares?
- Unexpected difference between diffs of hashes vs. arrays HOT 5
- Conflicts with `hash_diff` HOT 50
- HashDiff never finishes when comparing two arrays HOT 3
- "use_lcs: false" does not work as expected as per documentation HOT 1
- Compare objects inheriting from the same class HOT 1
- version tags would be helpful to see diffs HOT 2
- Unexpected results HOT 1
- Please stop the `warn` spam HOT 6
- Canβt silence HashDiff constant warning HOT 6
- Issues with diff
- default similarity should be 1
- Getting (+-) instead of diff (tilde) when comparing arrays HOT 5
- Please document the determinism of HashDiff.diff and friends HOT 1
- ==/equal? overrides not used when checking keys
- [Feature request] :ignore_keys option HOT 3
- ignore_keys ignores only common keys HOT 5
- ignore_keys doesn't seem to work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashdiff.