Skip to content

Instantly share code, notes, and snippets.

View SirRawlins's full-sized avatar

Robert Rawlins SirRawlins

  • Sorry™
  • Chichester, UK
View GitHub Profile
@sshaw
sshaw / rspec-checksum-matchers.rb
Last active December 20, 2021 13:49
RSpec::Checksum::Matchers: Check if a String looks like a digest produced a the given hash algorithm. Also see https://github.com/sshaw/has_checksum
# RSpec::Checksum::Matchers Check if a String looks like a checksum produced by the given algorithm.
# https://gist.github.com/sshaw/df14f6f89860b2dbcfd2
#
# Copyright (c) 2016 Skye Shaw. Released under the MIT License (https://opensource.org/licenses/MIT)
#
require "rspec/expectations"
RSpec::Matchers.define :be_a_checksum do
regex = /\A[0-9a-f]{32,128}\z/i
chars = {