Code Monkey home page Code Monkey logo

Comments (7)

icy-arctic-fox avatar icy-arctic-fox commented on May 27, 2024

This can be worked around (and might be preferred) to use the match_array matcher instead.

This should work, since it's valid Crystal syntax, so I'll look at providing a fix.

from spectator.

postmodern avatar postmodern commented on May 27, 2024

In my example findings can contain exactly the expected_metdata Array of Tuples when it's ran on my machine. When I run the specs on a Ubuntu system with Ubuntu's version of libextractor, then additional Tuples show up in findings. So I need something like RSpec's .to include(*array).

from spectator.

icy-arctic-fox avatar icy-arctic-fox commented on May 27, 2024

Would a non-splat version of contain work? That looks faster/easier to implement than fixing splatting within contain for now. Perhaps something like contain_elements(array_or_tuple)?

from spectator.

postmodern avatar postmodern commented on May 27, 2024

Could we overload contain to accept an Array(Tuple)?

from spectator.

icy-arctic-fox avatar icy-arctic-fox commented on May 27, 2024

There should be a fix in the latest version (0.9.22). Can you see if that works for you? This snippet worked for me:

Spectator.describe "GitHub Issue 8" do
  it "works without a splat" do
    expect([1, 2, 3, 4, 5]).to contain(2, 3, 4)
  end

  it "works with a splat" do
    elements = {2, 3, 4}
    expect([1, 2, 3, 4, 5]).to contain(*elements)
  end
end

from spectator.

postmodern avatar postmodern commented on May 27, 2024

Excellent. It compiles now. Still failing due to another weird equality issue that I'm still investigating; the same code works if I write it as plain crystal code and compare the two Array(Tuple) objects with ==.

from spectator.

icy-arctic-fox avatar icy-arctic-fox commented on May 27, 2024

Excellent. It compiles now. Still failing due to another weird equality issue that I'm still investigating; the same code works if I write it as plain crystal code and compare the two Array(Tuple) objects with ==.

Please let me know if you find an issue with this. That sounds like it could be a big issue.

The contain matcher uses this for its check:

expected.value.all? do |item|
  actual.includes?(item)
end

The includes? method uses the == operator, should everything should be okay...
https://github.com/crystal-lang/crystal/blob/5999ae29b/src/enumerable.cr#L616

from spectator.

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.