spec/option_spec.rb in option-1.1.0 vs spec/option_spec.rb in option-1.2.0
- old
+ new
@@ -88,10 +88,22 @@
end
it "#flatten should return itself" do
None.flatten.must_be_none
end
+
+ it "#error should raise a RuntimeError with the given message" do
+ lambda { None.error("error") }.must_raise RuntimeError, "error"
+ end
+
+ it "#error should raise the error passed to it" do
+ -> { None.error(ArgumentError.new("name")) }.must_raise ArgumentError, "name"
+ end
+
+ it "should assemble an Error from the arguments passed in" do
+ -> { None.error(StandardError, "this is a problem") }.must_raise StandardError, "this is a problem"
+ end
end
describe SomeClass do
it "#to_a returns the value wrapped in an array" do
@@ -192,9 +204,14 @@
it "#flatten" do
inner_value = Some(Some(Some(value))).flatten
inner_value.must_be_some(value)
inner_value.or_nil.must_equal(value)
+ end
+
+ it "#error should return the Some" do
+ value = !!(Some(value).error("error") rescue false)
+ value.must_equal true
end
end
describe OptionClass do