Sha256: 3cfd983e2f56c733dd2379159a9f56bd54d1fef90080ec360cc9b8cbfa77a0a3

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe "Semi::validator" do

  [
    [10,         'integer',                        true],
    [10,         ['integer'],                      true],
    ['10',       'integer',                        false],
    ['10',       ['integer'],                      false],
    ['foobar',   'string',                         true],
    ['foobar',   ['string', 'required'],           true],
    ['foobar',   'string,required',                true],
    ['foobar',   'string, required',               true],
    ['foobar',   '/foo/',                          true],
    ['foobar',   '/fubar/',                        false],
    ['foobar',   ['/foo/'],                        true],
    ['foobar',   ['/fubar/'],                      false],
    [nil,        'required',                       false],
    [nil,        ['required'],                     false]
   ].each do |ruleset|
    it "validates #{ruleset[0]} against #{ruleset[1]}" do
      if ruleset[2] == true
        expect {Semi::validate(ruleset[0], ruleset[1])}.not_to raise_error
      else
        expect {Semi::validate(ruleset[0], ruleset[1])}.to raise_error(Semi::ValidationError)
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
semi-0.2.1 spec/semi_validator_spec.rb
semi-0.2.0 spec/semi_validator_spec.rb