Sha256: 7e1c43e7904aec47ffe09bf92de435b7673d513ea6492ac6b98ad1e35850cdba
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
require "spec_helper" class Model include ActiveModel::Validations attr_accessor :uri validates :uri, :uri => true end class SecureModel < Model validates :uri, :uri => { :protocol => "https" } end class AccessibleModel < Model validates :uri, :uri => { :accessible => true } end describe "Vidibus::ValidateUri::UriValidator" do let(:model) { Model.new } let(:secure_model) { SecureModel.new } let(:acessible_model) { AccessibleModel.new } it "should be available as URI validator" do Model.validators_on(:uri).first.should be_a_kind_of(Vidibus::ValidateUri::UriValidator) end it "should add an error to model if URI is blank" do model.uri = nil model.should be_invalid model.errors[:uri].should eql(["is invalid"]) end it "should add an error to model if URI is invalid" do model.uri = "http://localhosts" model.should be_invalid model.errors[:uri].should eql(["is invalid"]) end it "should add no error to model if URI is valid" do model.uri = "http://vidibus.org" model.should be_valid end it "should add an error if uri does not match provided protocols" do secure_model.uri = "http://www.vidibus.org" secure_model.should be_invalid secure_model.errors[:uri].should have(1).error end it "should add an error to model if URI is inaccessible" do acessible_model.uri = "http://vidibus.zzz" acessible_model.should be_invalid acessible_model.errors[:uri].should eql(["is inaccessible"]) end end
Version data entries
6 entries across 6 versions & 1 rubygems