1 #!/usr/bin/env ruby -S rspec
4 describe Puppet::Parser::Functions.function(:has_ip_network) do
7 PuppetlabsSpec::PuppetInternals.scope
11 function_name = Puppet::Parser::Functions.function(:has_ip_network)
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('network').returns(:undefined)
19 scope.stubs(:lookupvar).with('network_eth0').returns('10.0.2.0')
20 scope.stubs(:lookupvar).with('network_lo').returns('127.0.0.1')
23 it 'should have primary network (10.0.2.0)' do
24 expect(subject.call(['10.0.2.0'])).to be_truthy
27 it 'should have loopback network (127.0.0.0)' do
28 expect(subject.call(['127.0.0.1'])).to be_truthy
31 it 'should not have other network' do
32 expect(subject.call(['192.168.1.0'])).to be_falsey