Skip to content

Commit

Permalink
Add a method Hwinfo#merge!
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Aug 27, 2019
1 parent a95fda3 commit 6fe6e04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/y2network/hwinfo.rb
Expand Up @@ -123,6 +123,13 @@ def description
@hwinfo ? @hwinfo.fetch("name", "") : ""
end

# Merges data from another Hwinfo object
#
# @param other [Hwinfo] Object to merge data from
def merge!(other)
@hwinfo.merge!(other.hwinfo)
end

# Returns the list of kernel modules
#
# The list of modules is internally represented as:
Expand Down
12 changes: 12 additions & 0 deletions test/y2network/hwinfo_test.rb
Expand Up @@ -49,6 +49,18 @@
end
end

describe "#merge!" do
subject(:hwinfo) { described_class.new(mac: "00:11:22:33:44:55:66", busid: "0000:08:00.0") }
let(:other) { described_class.new(mac: "01:23:45:78:90:ab", dev_port: "1") }

it "merges data from another Hwinfo object" do
hwinfo.merge!(other)
expect(hwinfo.mac).to eq(other.mac)
expect(hwinfo.busid).to eq("0000:08:00.0")
expect(hwinfo.dev_port).to eq("1")
end
end

describe "#drivers" do
it "returns the list of kernel modules names" do
expect(hwinfo.drivers).to eq(
Expand Down

0 comments on commit 6fe6e04

Please sign in to comment.