lib/polytrix/validator.rb in polytrix-0.1.0 vs lib/polytrix/validator.rb in polytrix-0.1.1

- old
+ new

@@ -3,13 +3,14 @@ module Polytrix class Validator include RSpec::Matchers UNIVERSAL_MATCHER = // - attr_reader :suite, :sample, :level, :callback + attr_reader :description, :suite, :sample, :level, :callback - def initialize(scope = {}, &validator) + def initialize(description, scope = {}, &validator) + @description = description @suite = scope[:suite] ||= UNIVERSAL_MATCHER @sample = scope[:sample] ||= UNIVERSAL_MATCHER @callback = validator end @@ -17,8 +18,12 @@ !!(@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 + + def to_s + @description end end end