source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/functions/is_domain_name_spec.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 8 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1require 'spec_helper'
2
3describe 'is_domain_name' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
6 it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7 it { is_expected.to run.with_params(1).and_return(false) }
8 it { is_expected.to run.with_params([]).and_return(false) }
9 it { is_expected.to run.with_params({}).and_return(false) }
10 it { is_expected.to run.with_params('').and_return(false) }
11 it { is_expected.to run.with_params('.').and_return(true) }
12 it { is_expected.to run.with_params('com').and_return(true) }
13 it { is_expected.to run.with_params('com.').and_return(true) }
14 it { is_expected.to run.with_params('x.com').and_return(true) }
15 it { is_expected.to run.with_params('x.com.').and_return(true) }
16 it { is_expected.to run.with_params('foo.example.com').and_return(true) }
17 it { is_expected.to run.with_params('foo.example.com.').and_return(true) }
18 it { is_expected.to run.with_params('2foo.example.com').and_return(true) }
19 it { is_expected.to run.with_params('2foo.example.com.').and_return(true) }
20 it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) }
21 it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) }
22 describe 'inputs with spaces' do
23 it { is_expected.to run.with_params('invalid domain').and_return(false) }
24 end
25 describe 'inputs with hyphens' do
26 it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) }
27 it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) }
28 it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) }
29 it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) }
30 it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
31 it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
32 end
33 # Values obtained from Facter values will be frozen strings
34 # in newer versions of Facter:
35 it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) }
36 describe 'top level domain must be alphabetic if there are multiple labels' do
37 it { is_expected.to run.with_params('2com').and_return(true) }
38 it { is_expected.to run.with_params('www.example.2com').and_return(false) }
39 end
40 describe 'IP addresses are not domain names' do
41 it { is_expected.to run.with_params('192.168.1.1').and_return(false) }
42 end
43end
Note: See TracBrowser for help on using the repository browser.