Sha256: 231512820c6fd85e7b61a5817f99350a9dbe9ae2c98924dc3bc6058c801b4b76
Contents?: true
Size: 603 Bytes
Versions: 1
Compression:
Stored size: 603 Bytes
Contents
require 'rspec/expectations' module Polytrix class Validator include RSpec::Matchers UNIVERSAL_MATCHER = // attr_reader :suite, :sample, :level, :callback def initialize(scope = {}, &validator) @suite = scope[:suite] ||= UNIVERSAL_MATCHER @sample = scope[:sample] ||= UNIVERSAL_MATCHER @callback = validator end def should_validate?(challenge) !!(@suite.match(challenge.suite.to_s) && @sample.match(challenge.name.to_s)) end def validate(challenge) instance_exec challenge, &@callback if should_validate?(challenge) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polytrix-0.1.0 | lib/polytrix/validator.rb |