Sha256: 60e8f8d922766da21708a437650e70dff230ce91fc663576260dd159225c7381
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true class Quickdraw::Expectation def initialize(context, value = Quickdraw::Null, &block) if block && Quickdraw::Null != value raise Quickdraw::ArgumentError.new( "You must only provide a value or a block to `expect`." ) end @context = context @value = value @block = block @made_expectations = false end def success! @context.success! @made_expectations = true end def failure!(&) @context.failure!(&) @made_expectations = true end def resolve if !@made_expectations failure! { "You didn't make any expectations." } end end private def assert(value, &) value ? success! : failure!(&) end def refute(value, &) value ? failure!(&) : success! end def value if @block raise Quickdraw::ArgumentError.new( "You must pass a value rather than a block when using the #{caller_locations.first.label} matcher." ) else @value end end def block if @block @block else raise Quickdraw::ArgumentError.new( "You must pass a block rather than a value when using the #{caller_locations.first.label} matcher." ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickdraw-0.1.0 | lib/quickdraw/expectation.rb |