Skip to content

Instantly share code, notes, and snippets.

@uu59
Created September 2, 2012 14:53
Show Gist options
  • Select an option

  • Save uu59/3599963 to your computer and use it in GitHub Desktop.

Select an option

Save uu59/3599963 to your computer and use it in GitHub Desktop.
# http://r7kamura.hatenablog.com/entry/2012/09/02/185129
# https://gist.github.com/3595761
# https://gist.github.com/3595759
require "spec_helper"
describe Avalon::Validator do
let(:validator) do
proc do |arg|
Avalon::Validator.new("target", arg)
end.curry
end
let(:error) do
raise_error(Avalon::ValidationError)
end
def check(arg)
expect do
validator[arg].validate
end
end
describe "#validate" do
context "given valid arg" do
it "by String" do
check("target").not_to error
end
it "by RegExp" do
check(/target/).not_to error
end
end
context "given invalid arg" do
it "by String" do
check("no match").to error
end
it "by RegExp" do
check(/no match/).to error
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment