From 039f82576f62ffb26f42df146c1072df77186748 Mon Sep 17 00:00:00 2001 From: David Hollinger Date: Wed, 15 Aug 2018 16:30:39 -0500 Subject: [PATCH] Add puppet_munge test to provider tests --- .../network_route/network_route_spec.rb | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/spec/unit/puppet/provider/network_route/network_route_spec.rb b/spec/unit/puppet/provider/network_route/network_route_spec.rb index cc868d08..f7de630d 100644 --- a/spec/unit/puppet/provider/network_route/network_route_spec.rb +++ b/spec/unit/puppet/provider/network_route/network_route_spec.rb @@ -23,16 +23,32 @@ module Puppet::Provider::NetworkRoute; end [ { default_route: true, - ensure: "present", - gateway: "10.0.2.2", - interface: "enp0s3", - metric: "100", - prefix: "default", - protocol: "dhcp" + ensure: 'present', + gateway: '10.0.2.2', + interface: 'enp0s3', + metric: '100', + prefix: 'default', + protocol: 'dhcp' } ] end + describe '#puppet_munge(should)' do + let(:should) { network_route[0] } + + it 'should parse network_route into iproute2 keys' do + expect(provider.puppet_munge(should)).to eq( + { + dev: 'enp0s3', + metric: '100', + prefix: 'default', + proto: 'dhcp', + via: '10.0.2.2', + } + ) + end + end + describe '#get' do before(:each) do allow(provider).to receive(:routes_list).and_return(route) # rubocop:disable RSpec/SubjectStub @@ -40,20 +56,17 @@ module Puppet::Provider::NetworkRoute; end it 'processes resources' do expect(provider.get(context)).to eq( - [{:default_route=>true, - :ensure=>"present", - :gateway=>"10.0.2.2", - :interface=>"enp0s3", - :metric=>"100", - :prefix=>"default", - :protocol=>"dhcp"}] + [{default_route: true, + ensure: 'present', + gateway: '10.0.2.2', + interface: 'enp0s3', + metric: '100', + prefix: 'default', + protocol: 'dhcp'}] ) end end - describe '#puppet_munge(should)' do - end - # describe 'create(context, name, should)' do # it 'creates the resource' do # expect(context).to receive(:notice).with(%r{\ACreating 'a'})