Jacob MaineJacob Maine
SF Standup 3/4-3/5/2010
edit Posted by Jacob Maine on Friday March 05, 2010 at 09:25AM

Help

"What's the best way to test that an array contains another array?"

A custom matcher using array - other_array was suggested.

Interesting

The team that was having problems with Prototype response codes found a partial solution.

They sometimes call abort() on the request which triggers the callbacks with a 0 response code. They found that if they set transport.onreadystatechange = function() {}; before calling abort() they could skip the callbacks, and manually call whatever clean-up they needed. That Prototype interprets 0 as a success still sounds strange.

Comments

  1. Stephan Wehner Stephan Wehner on March 05, 2010 at 12:07PM

    Not sure I understand the "Help" question. Is assert a1.include?(a2) good enough?

    $ irb
    irb(main):001:0> a = [ [1], [2,3], [4,5,6]]
    => [[1], [2, 3], [4, 5, 6]]
    irb(main):002:0> a.include?([2,3])
    => true
    irb(main):003:0> a.include?([1,2,3])
    => false
    

    Stephan

  2. Josh Susser Josh Susser on March 05, 2010 at 01:59PM

    The problem was how to test if an array includes the contents of another array, as opposed to including the other array object itself. Splatting the other array works fine:

    it "includes related tags"
      w[ruby rails rspec testing].should include(*article.tags)
    end