]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / has_ip_network_spec.rb
1 #!/usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe Puppet::Parser::Functions.function(:has_ip_network) do
5
6   let(:scope) do
7     PuppetlabsSpec::PuppetInternals.scope
8   end
9
10   subject do
11     function_name = Puppet::Parser::Functions.function(:has_ip_network)
12     scope.method(function_name)
13   end
14
15   context "On Linux Systems" do
16     before :each 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')
21     end
22
23     it 'should have primary network (10.0.2.0)' do
24       expect(subject.call(['10.0.2.0'])).to be_truthy
25     end
26
27     it 'should have loopback network (127.0.0.0)' do
28       expect(subject.call(['127.0.0.1'])).to be_truthy
29     end
30
31     it 'should not have other network' do
32       expect(subject.call(['192.168.1.0'])).to be_falsey
33     end
34   end
35 end
36