Skip to content
This repository
Browse code

Merge pull request #275 from opscode/provides-map-plugin-uniqueness

collect unique attributes for provides/depends
  • Loading branch information...
commit 17369e52c7e510d62a20c9dd5e144e5dd86c988a 2 parents fc72e66 + 3e7b138
Claire McQuin mcquin authored
4 lib/ohai/dsl/plugin/versionvii.rb
@@ -56,13 +56,13 @@ def self.data_collector
56 56
57 57 def self.provides(*attrs)
58 58 attrs.each do |attr|
59   - provides_attrs << attr
  59 + provides_attrs << attr unless provides_attrs.include?(attr)
60 60 end
61 61 end
62 62
63 63 def self.depends(*attrs)
64 64 attrs.each do |attr|
65   - depends_attrs << attr
  65 + depends_attrs << attr unless depends_attrs.include?(attr)
66 66 end
67 67 end
68 68
12 spec/unit/dsl/plugin_spec.rb
@@ -143,6 +143,12 @@
143 143 plugin = Ohai.plugin(@name) { provides("two", "three") }
144 144 plugin.provides_attrs.should eql(["one", "two", "three"])
145 145 end
  146 +
  147 + it "should collect unique attributes" do
  148 + plugin = Ohai.plugin(@name) { provides("one") }
  149 + plugin = Ohai.plugin(@name) { provides("one", "two") }
  150 + plugin.provides_attrs.should eql(["one", "two"])
  151 + end
146 152 end
147 153
148 154 describe "#depends" do
@@ -170,6 +176,12 @@
170 176 plugin = Ohai.plugin(@name) { depends("two", "three") }
171 177 plugin.depends_attrs.should eql(["one", "two", "three"])
172 178 end
  179 +
  180 + it "should collect unique attributes" do
  181 + plugin = Ohai.plugin(@name) { depends("one") }
  182 + plugin = Ohai.plugin(@name) { depends("one", "two") }
  183 + plugin.depends_attrs.should eql(["one", "two"])
  184 + end
173 185 end
174 186
175 187 describe "#collect_data" do

0 comments on commit 17369e5

Please sign in to comment.
Something went wrong with that request. Please try again.