Sha256: 6f4e338b0850370a97131dfa267d2345c7fb6c5539e9526d4d06582762cc928e
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), "..", "spec_helper") describe Glyph::Macro::Validators do before do Glyph.run! 'load:all' Glyph.macro :validated_test do validate("Invalid Macro"){ @value == "valid" } "Validated Test: #{@value}" end end it "should provide custom validation" do lambda { interpret("section[validated_test[invalid]]").document.output }.should raise_error Glyph::MacroError lambda { interpret("chapter[validated_test[valid]]").document.output }.should_not raise_error end it "should validate the number of parameters" do # exact lambda { interpret("table[]").document.output }.should raise_error Glyph::MacroError # none lambda { interpret("toc[test]").document.output }.should raise_error Glyph::MacroError # min lambda { interpret("img[]").document.output }.should raise_error Glyph::MacroError # max lambda { interpret("not[a|b|c]").document.output }.should raise_error Glyph::MacroError # correct lambda { interpret("chapter[fmi[something|#something]]").document.output }.should_not raise_error Glyph::MacroError end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glyph-0.2.0 | spec/lib/macro_validators_spec.rb |