Created
September 2, 2012 14:53
-
-
Save uu59/3599963 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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