37
|
1 #!/usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper'
|
|
3
|
|
4 describe Puppet::Parser::Functions.function(:has_ip_address) 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_address)
|
|
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('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')
|
|
21 end
|
|
22
|
|
23 it 'should have primary address (10.0.2.15)' do
|
|
24 expect(subject.call(['10.0.2.15'])).to be_truthy
|
|
25 end
|
|
26
|
|
27 it 'should have lookupback address (127.0.0.1)' do
|
|
28 expect(subject.call(['127.0.0.1'])).to be_truthy
|
|
29 end
|
|
30
|
|
31 it 'should not have other address' do
|
|
32 expect(subject.call(['192.1681.1.1'])).to be_falsey
|
|
33 end
|
|
34
|
|
35 it 'should not have "mspiggy" on an interface' do
|
|
36 expect(subject.call(['mspiggy'])).to be_falsey
|
|
37 end
|
|
38 end
|
|
39 end
|