Last active
December 15, 2015 01:29
-
-
Save artm/5180707 to your computer and use it in GitHub Desktop.
DRYer specs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Something | |
def self.foo a, *args | |
a.zip(*args).flatten.select{|e|e} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'something' | |
describe Something do | |
{ | |
"with 1 array" => [ [1,2,3] ], | |
"with 2 arrays" => [ [1,2,3], [4,5,6] ], | |
"with more than 2 arrays" => [ [1,2,3], [4,5,6], [7], [8,9] ], | |
}.each do |title,data| | |
describe title do | |
it "returns all elements" do | |
Something.foo(*data).count.must_equal data.reduce(0){|sum,a|sum+a.count} | |
do | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment