Skip to content

Commit

Permalink
Improve Y2Network::Route to/interface handling in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs authored and mchf committed Mar 21, 2019
1 parent 1ace623 commit e13910c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/y2network/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Route
# @return [IPAddr,nil]
attr_reader :gateway

def initialize(to, interface, gateway: nil, source: nil, preference: nil)
def initialize(to: :default, interface: :any, gateway: nil, source: nil, preference: nil)
@to = to
@interface = interface
@gateway = gateway
Expand All @@ -40,7 +40,7 @@ def initialize(to, interface, gateway: nil, source: nil, preference: nil)
#
# @return [Boolean]
def default?
@to.nil?
to == :default
end
end
end
4 changes: 2 additions & 2 deletions test/y2network/route_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

describe Y2Network::Route do
subject(:route) do
described_class.new(to, interface)
described_class.new(to: to, interface: interface)
end

let(:to) { IPAddr.new("192.168.122.1") }
let(:interface) { Y2Network::Interface.new("eth0") }

describe "#default?" do
context "when it is the default route" do
let(:to) { nil }
let(:to) { :default }

it "returns true" do
expect(route.default?).to eq(true)
Expand Down

0 comments on commit e13910c

Please sign in to comment.