1 #!/usr/bin/env ruby -S rspec
4 describe Puppet::Parser::Functions.function(:has_ip_address) do
7 PuppetlabsSpec::PuppetInternals.scope
11 function_name = Puppet::Parser::Functions.function(:has_ip_address)
12 scope.method(function_name)
15 context "On Linux Systems" do
17 scope.stubs(:lookupvar).with('interfaces').returns('eth0,lo')
18 scope.stubs(:lookupvar).with('ipaddress').returns('10.0.2.15')
19 scope.stubs(:lookupvar).with('ipaddress_eth0').returns('10.0.2.15')
20 scope.stubs(:lookupvar).with('ipaddress_lo').returns('127.0.0.1')
23 it 'should have primary address (10.0.2.15)' do
24 expect(subject.call(['10.0.2.15'])).to be_truthy
27 it 'should have lookupback address (127.0.0.1)' do
28 expect(subject.call(['127.0.0.1'])).to be_truthy
31 it 'should not have other address' do
32 expect(subject.call(['192.1681.1.1'])).to be_falsey
35 it 'should not have "mspiggy" on an interface' do
36 expect(subject.call(['mspiggy'])).to be_falsey