Sha256: 974559a84e919194f693dd41be5ae14b00f4bdfeb633988c66ce1102f3e11d77
Contents?: true
Size: 578 Bytes
Versions: 2
Compression:
Stored size: 578 Bytes
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) class SizeMacro < AssertionMacro register :size def evaluate(actual, expected) failure_message = "size of #{actual.inspect} expected to be #{expected} but is #{actual.size}" expected === actual.size ? pass("is of size #{expected}") : fail(failure_message) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riot-0.10.11 | lib/riot/assertion_macros/size.rb |
riot-0.10.10 | lib/riot/assertion_macros/size.rb |