From d78b719df2a6ef127f7becb9b7b7be25a4260560 Mon Sep 17 00:00:00 2001 From: Tom Doherty Date: Fri, 8 Sep 2017 16:17:45 +0100 Subject: Simplify and add unit test for default route Signed-off-by: Tom Doherty --- spec/unit/provider/route_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec') diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index 2beb765259..a9c7d91457 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -29,9 +29,14 @@ describe Chef::Provider::Route do @new_resource.gateway "10.0.0.9" @current_resource = Chef::Resource::Route.new("10.0.0.10") @current_resource.gateway "10.0.0.9" + @default_resource = Chef::Resource::Route.new("default") + @default_resource.gateway "10.0.0.9" @provider = Chef::Provider::Route.new(@new_resource, @run_context) @provider.current_resource = @current_resource + + @default_provider = Chef::Provider::Route.new(@default_resource, @run_context) + @default_provider.current_resource = @default_resource end describe Chef::Provider::Route, "hex2ip" do @@ -161,6 +166,11 @@ describe Chef::Provider::Route do @new_resource.gateway(nil) expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/) end + + it "should use the gatway when target is default" do + @default_resource.gateway("10.0.0.10") + expect(@default_provider.generate_command(:add).join(" ")).to match(/10.0.0.10/) + end end describe Chef::Provider::Route, "generate_command for action_delete" do -- cgit v1.2.1