Sha256: 010d95f3db58ce9d76aece9714982568192d256eaaefae449cd432f34b4c5399

Contents?: true

Size: 510 Bytes

Versions: 10

Compression:

Stored size: 510 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_message.elements(expected).to_match(actual))
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
riot-0.11.4 lib/riot/assertion_macros/same_elements.rb
riot-0.11.4.pre lib/riot/assertion_macros/same_elements.rb
riot-0.11.3 lib/riot/assertion_macros/same_elements.rb
riot-0.11.2 lib/riot/assertion_macros/same_elements.rb
riot-0.11.1 lib/riot/assertion_macros/same_elements.rb
riot-0.11.0 lib/riot/assertion_macros/same_elements.rb
riot-0.10.13 lib/riot/assertion_macros/same_elements.rb
riot-0.10.13.pre lib/riot/assertion_macros/same_elements.rb
riot-0.10.12 lib/riot/assertion_macros/same_elements.rb
riot-0.10.12.pre lib/riot/assertion_macros/same_elements.rb