Skip to content

Commit

Permalink
extend tests also for other containers and one more fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 8, 2022
1 parent 63aecce commit fe20557
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dbus/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def self.from_typed(value, member_types:) # rubocop:disable Lint/UnusedMethodArg
# assert member_types.empty?

# decide on type of value
new(value)
new(value, member_type: member_types.first)
end

# Note that for Variants type=="v",
Expand Down
13 changes: 13 additions & 0 deletions spec/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,22 @@

include_examples "constructor (kwargs) accepts values", good
# include_examples "constructor (kwargs) rejects values", bad

describe ".from_typed" do
it "creates new instance from given object and type" do
type = DBus::Type.new("s")
expect(described_class.from_typed(["test", "lest"].freeze, member_types: [type, type])).to be_a(described_class)
end
end
end

describe DBus::Data::Variant do
describe ".from_typed" do
it "creates new instance from given object and type" do
type = DBus::Type.new("s")
expect(described_class.from_typed("test", member_types: [type])).to be_a(described_class)
end
end
end

describe DBus::Data::DictEntry do
Expand Down

0 comments on commit fe20557

Please sign in to comment.