Sha256: 451acdc88a06ae186bd4f27b0c5a8a4037cf7e08452ec175ac2d40545bf3e4d1
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
module Riot # Asserts that result's size is as expected. Expected size can be specified as # a number or a range. # # asserts("a string") { 'washington' }.size(9..12) # asserts("an array") { [1, 2, 3] }.size(3) # asserts("a hash") { {:name => 'washington'} }.size(1) # # To ensure that the result is not of a specific size: # # denies("a string") { 'washington' }.size(4) # denies("an array") { [1, 2, 3] }.size(6..10) # denies("a hash") { {:name => 'washington'} }.size(2) class SizeMacro < AssertionMacro register :size def evaluate(actual, expected) failure_message = expected_message.size_of(actual).to_be(expected).not(actual.size) expected === actual.size ? pass(new_message.is_of_size(expected)) : fail(failure_message) end def devaluate(actual, expected) failure_message = expected_message.size_of(actual).to_not_be(expected).not(actual.size) expected === actual.size ? fail(failure_message) : pass(new_message.is_not_size(expected)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riot-0.12.1 | lib/riot/assertion_macros/size.rb |
riot-0.12.0 | lib/riot/assertion_macros/size.rb |
riot-0.12.0.pre | lib/riot/assertion_macros/size.rb |