Sha256: 71f3851df5b37ec9633dcf2b7d4dce8902f66d8b96159560ae514b22deed8f28
Contents?: true
Size: 1.37 KB
Versions: 6
Compression:
Stored size: 1.37 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'hamster/list' describe Hamster::List do [:remove, :reject, :delete_if].each do |method| describe "##{method}" do it "is lazy" do lambda { Hamster.stream { fail }.send(method) { |item| false } }.should_not raise_error end [ [[], []], [["A"], ["A"]], [["A", "B", "C"], ["A", "B", "C"]], [["A", "b", "C"], ["A", "C"]], [["a", "b", "c"], []], ].each do |values, expected| describe "on #{values.inspect}" do before do @original = Hamster.list(*values) end describe "with a block" do before do @result = @original.send(method) { |item| item == item.downcase } end it "returns #{expected.inspect}" do @result.should == Hamster.list(*expected) end it "is lazy" do count = 0 @original.send(method) { |item| count += 1; false } count.should <= 1 end end describe "without a block" do before do @result = @original.send(method) end it "returns self" do @result.should equal(@original) end end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems