class Insist

Insist on correctness.

Example:

data = { "hello" => "world" }
insist { data["hello"] } == "world"

This class aims to work similarly to how rspec’s “should” stuff does, but instead of molesting Object allows you to neatly wrap values with blocks while still checking for expected values.

Public Class Methods

new(&block) click to toggle source

Create a new insist with a block.

Example:

Insist.new { value }

Better:

insist { value }
# File lib/insist.rb, line 41
def initialize(&block)
  @callback = block
end

Public Instance Methods

value() click to toggle source
# File lib/insist.rb, line 45
def value
  # TODO(sissel): make caching the value optional
  @value ||= @callback.call
  return @value
end