Sha256: 83f5804e812660615a90917ffef093e59d38202543bd8c9b8384b6c5e11607b9
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
require "insist/namespace" require "insist/assert" require "insist/comparators" require "insist/enumerables" require "insist/failure" require "insist/nil" require "insist/predicates" require "insist/raises" # 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. class Insist class Failure < StandardError; end include Insist::Comparators include Insist::Enumerables include Insist::Nil include Insist::Assert include Insist::Raises include Insist::Predicates # Create a new insist with a block. # # Example: # # Insist.new { value } # # Better: # # insist { value } def initialize(&block) @callback = block end # def initialize def value # TODO(sissel): make caching the value optional @value ||= @callback.call return @value end # def value end # class Insist module Kernel # A shortcut to 'Insist.new' # # Example: # # insist { "hello world" } != "fizzle" def insist(&block) return Insist.new(&block) end # def insist end # module Kernel
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
insist-0.0.5 | lib/insist.rb |
insist-0.0.4 | lib/insist.rb |