Sha256: fda24eb847df1f3aaa07ad6db5f7419cbfb8cbaa892dac728403f0c71240ba79
Contents?: true
Size: 524 Bytes
Versions: 2
Compression:
Stored size: 524 Bytes
Contents
module Riot # Asserts that two arrays contain the same elements, the same number of times. # asserts("test") { ["foo", "bar"] }.same_elements(["bar", "foo"]) # should("test") { ["foo", "bar"] }.same_elements(["bar", "foo"]) class SameElementsMacro < AssertionMacro register :same_elements def evaluate(actual, expected) require 'set' same = (Set.new(expected) == Set.new(actual)) same ? pass : fail("expected elements #{expected.inspect} to match #{actual.inspect}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riot-0.10.11 | lib/riot/assertion_macros/same_elements.rb |
riot-0.10.10 | lib/riot/assertion_macros/same_elements.rb |