Sha256: 803c4d7a50eb22f87aeb4c0011d23a6f36f7d6e888c9e6fa354173b9c82c691f
Contents?: true
Size: 1.01 KB
Versions: 23
Compression:
Stored size: 1.01 KB
Contents
RSpec::Matchers.define :succeed_on do |input| match do |operation| @operation, @input = operation, input success? && return_value_matches? end match_when_negated do |operation| raise NotImplementedError, '`expect().not_to succeed_on(input).returning()` is not supported.' if @value @operation, @input = operation, input !success? end chain :returning do |value| @value = value end description do "be successful" end failure_message do if !success? "Expected operation to be successful but failed with :#{result.error.type} error" else "Expected successful operation to return #{description_of(@value)} but instead got #{description_of(result.value)}" end end failure_message_when_negated do "Did not to expected operation to be successful but it was" end def success? result.success? end def return_value_matches? @value.nil? || values_match?(@value, result.value) end def result @result ||= @operation.call(@input) end end
Version data entries
23 entries across 23 versions & 1 rubygems