spec/hamster/set/remove_spec.rb in hamster-0.1.22 vs spec/hamster/set/remove_spec.rb in hamster-0.1.23
- old
+ new
@@ -2,43 +2,59 @@
require 'hamster/set'
describe Hamster::Set do
- describe "#remove" do
+ [:remove, :reject, :delete_if].each do |method|
- before do
- @original = Hamster.set("A", "B", "C")
- end
+ describe "##{method}" do
- describe "with an existing value" do
-
before do
- @result = @original.remove("B")
+ @original = Hamster.set("A", "B", "C")
end
- it "preserves the original" do
- @original.should == Hamster.set("A", "B", "C")
- end
+ describe "when nothing matches" do
- it "returns a copy with the remaining of values" do
- @result.should == Hamster.set("A", "C")
+ before do
+ @result = @original.send(method) { |item| false }
+ end
+
+ it "returns self" do
+ @result.should equal(@original)
+ end
+
end
- end
+ describe "when only some things match" do
- describe "with a non-existing value" do
+ describe "with a block" do
- before do
- @result = @original.remove("D")
- end
+ before do
+ @result = @original.send(method) { |item| item == "A" }
+ end
- it "preserves the original values" do
- @original.should == Hamster.set("A", "B", "C")
- end
+ it "preserves the original" do
+ @original.should == Hamster.set("A", "B", "C")
+ end
- it "returns self" do
- @result.should equal(@original)
+ it "returns a set with the matching values" do
+ @result.should == Hamster.set("B", "C")
+ end
+
+ end
+
+ describe "with no block" do
+
+ before do
+ @result = @original.send(method)
+ end
+
+ it "returns self" do
+ @result.should equal(@original)
+ end
+
+ end
+
end
end
end