spec/option_spec.rb in option-0.4.0 vs spec/option_spec.rb in option-0.5.0
- old
+ new
@@ -1,29 +1,7 @@
-require "minitest/autorun"
-require "minitest/pride"
-require "minitest/spec"
+require "spec_helper"
-require "option"
-
-module MiniTest::Assertions
-
- def assert_some(value, option, msg = nil)
- assert (option.is_a?(Some) && option.or_nil == value), "Expected Some(#{value})"
- end
-
- def assert_none(value, option, msg = nil)
- assert option == None, "Expected None"
- end
-end
-
-OptionClass.infect_an_assertion :assert_some, :must_be_some
-OptionClass.infect_an_assertion :assert_none, :must_be_none
-
-def value
- 12
-end
-
describe NoneClass do
it "#to_a returns an empty array" do
None.to_a.must_equal([])
end
@@ -136,10 +114,10 @@
it "#empty? should be false" do
Some(value).empty?.must_equal(false)
end
- it "#map should return the result of the proc over the value in an Option" do
+ it "#map should return the result of the proc over the value in a Some" do
Some(value).map { |v| v * 2 }.must_be_some(24)
end
it "#flat_map should raise TypeError if the returned value is not an Option" do
lambda { Some(value).flat_map { |v| v * 2 } }.must_raise TypeError