v1.8.0
Added
-
New extension for RSpec (@flash-gordon in #183): One of the pain points of testing monads is referencing class constants from specs. This extension catches missing class constants, analyzes the call site and returns a matching constant.
Before, this code would raise a
NameErrorbecauseFailureis a constant that is missing inObject:example "missing constant" do expect(call_operation).to eql(Failure[:some_error, "some message"]) endNow, after enabling the extension, it will return the correct constant:
Dry::Monads.load_extensions(:rspec) example "missing constant" do Failure[:some_error, "some message"] # => Failure[:some_error, "some message"] endOut of the box, the extension will check if
Success,Failure,Some, andNoneare referenced from a file ending with_spec.rb.More involved analysis is possible if you add
debug_inspectorto your Gemfile:group :test do gem "debug_inspector" end