Hi, I have array1 that contains several web address. Array2 contains the expected endings of array1 values. How can I control that arrays2 values is in array1? I have tried array1.should include array2, but it requires that array1 and array2 is identical. array1 = ["https://..../page.html, https://..../page1.html, https://..../page3.html] array2 = ["page.html", "page2.html", "page3.html", "page4.html"] A big thanks in advance! Regards Mattias -- Posted via http://www.ruby-forum.com/.
(Array1 - array2).should be_blank maybe? On 28 Feb 2013 07:42, "Mattias A." <lists at ruby-forum.com> wrote:> Hi, > > I have array1 that contains several web address. Array2 contains the > expected endings of array1 values. How can I control that arrays2 values > is in array1? > > I have tried array1.should include array2, but it requires that array1 > and array2 is identical. > > > array1 = ["https://..../page.html, https://..../page1.html, > https://..../page3.html] > > array2 = ["page.html", "page2.html", "page3.html", "page4.html"] > > A big thanks in advance! > > Regards > Mattias > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20130228/dfdb83ab/attachment.html>
Misunderstood examples.
Array1.collect{|s| s.split (''/'').last}.should == array2 seems
closer to
your intent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20130228/0158da13/attachment.html>
It appears to duplicate implementation. Perhaps this can do:
array2.each do |s2|
array1.should be_any do |s1|
s1.include s2
end
end
Or use zip instead
Sent from my BlackBerry? smartphone from Sinyal Bagus XL, Nyambung Teruuusss...!
-----Original Message-----
From: Ervin Weber <webervin at gmail.com>
Sender: rspec-users-bounces at rubyforge.org
Date: Thu, 28 Feb 2013 08:35:36
To: rspec-users<rspec-users at rubyforge.org>
Reply-To: rspec-users <rspec-users at rubyforge.org>
Subject: Re: [rspec-users] Simular to Include
_______________________________________________
rspec-users mailing list
rspec-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users