Sha256: 7902fe4e5568a6a26ae6d5815e90baef84d310e511cdcaa78b525a4cdbf77a3a

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

require 'spec_helper'

describe HostNameValidator do
  context 'when host_name is invalid' do
    before :each do
      @server = Server.new(:host_name => 'http://')
    end

    it 'should set object as invalid' do
      expect(@server.valid?).to be_falsey
    end

    it 'should set an error' do
      @server.valid?
      expect(@server.errors[:host_name]).to eq(['is invalid'])
    end
  end

  context 'when host_name is valid' do
    before :each do
      @server = Server.new(:host_name => 'bd01')
    end

    it 'should set object as valid' do
      expect(@server.valid?).to be_truthy
    end

    it 'should not set an error on attribute' do
      @server.valid?
      expect(@server.errors[:host_name]).to be_blank
    end
  end

  it 'should be valid with a nil value' do
    @server = Server.new(:host_name => nil)
    expect(@server.valid?).to be_truthy
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_host-1.1.0 spec/validates_host/host_name_validator_spec.rb