spec/option_spec.rb in option-0.1.0 vs spec/option_spec.rb in option-0.1.1

- old
+ new

@@ -54,10 +54,18 @@ it "#fold should invoke the default proc" do None.fold(proc { value }) { |v| v.to_f }.must_equal(value) end + it "#filter with a true predicate returns itself" do + Option(value).filter { |i| i == 12 }.must_equal(Option(value)) + end + + it "#filter with a false predicate returns None" do + Option(value).filter { |i| i == 1 }.must_equal(None) + end + it "should be aliased to None" do None.must_be_instance_of(NoneClass) end end @@ -125,9 +133,13 @@ Some(value).exists? { |v| v % 2 != 0 }.must_equal(false) end it "#fold should map the proc over the value and return it" do Some(value).fold(proc { value * 2 }) { |v| v * 3 }.must_equal(36) + end + + it "#filter should return itself" do + None.filter { |i| i == 0 }.must_equal(None) end it "should wrap the creation of a Some" do Some(value).must_be_instance_of(SomeClass) end