spec/option_spec.rb in option-0.6.0 vs spec/option_spec.rb in option-1.0.0
- old
+ new
@@ -43,10 +43,14 @@
it "#exists? should return false" do
None.exists? {}.must_equal(false)
end
+ it "#include? should return false" do
+ None.include?(value).must_equal(false)
+ end
+
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
@@ -142,10 +146,18 @@
it "#exists? should return false when the block evaluates false" do
Some(value).exists? { |v| v % 2 != 0 }.must_equal(false)
end
+ it "#include? should return true when the passed value and the boxed value are the same" do
+ Some(value).include?(value).must_equal(true)
+ end
+
+ it "#include? should return false when the passed value and the boxed value are not the same" do
+ Some(value).include?(value + 1).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
@@ -169,10 +181,12 @@
it "should be aliased to Some" do
Some.new(value).must_be_some(value)
end
it "#flatten" do
- Some(Some(Some(value))).flatten.must_be_some(value)
+ inner_value = Some(Some(Some(value))).flatten
+ inner_value.must_be_some(value)
+ inner_value.or_nil.must_equal(value)
end
end
describe OptionClass do