Giter Club home page Giter Club logo

Comments (4)

liufengyun avatar liufengyun commented on August 21, 2024

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.

wimrijnders avatar wimrijnders commented on August 21, 2024

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.

liufengyun avatar liufengyun commented on August 21, 2024

Indeed the documentation can be improved a bit to avoid confusion.

from hashdiff.

wimrijnders avatar wimrijnders commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.