lib/onceover/test.rb in onceover-3.2.5 vs lib/onceover/test.rb in onceover-3.2.6

- old
+ new

@@ -9,28 +9,26 @@ attr_reader :tags # This can accept a bunch of stuff. It can accept nodes, classes or groups anywhere # it will then detect them and expand them out into their respective objects so that # we just end up with a list of nodes and classes - #def initialize(on_this,test_config['classes'],options = {}) - def initialize(on_this,test_this,test_config) + def initialize(on_this, test_this, test_config) @default_test_config = { - 'check_idempotency' => true, + 'check_idempotency' => true, 'runs_before_idempotency' => 1 } # Add defaults if they do not exist test_config = @default_test_config.merge(test_config) - @nodes = [] + @nodes = [] @classes = [] @test_config = test_config @test_config.delete('classes') # remove classes from the config @tags = @test_config['tags'] - # Make sure that tags are an array @test_config['tags'] = [@test_config['tags']].flatten if @test_config['tags'] # Get the nodes we are working on if Onceover::Group.find(on_this) @@ -62,16 +60,16 @@ @classes << test_this end end def eql?(other) - (@nodes.sort.eql?(other.nodes.sort)) and (@classes.sort.eql?(other.classes.sort)) + @nodes.sort.eql?(other.nodes.sort) and @classes.sort.eql?(other.classes.sort) end def to_s class_msg = "" - node_msg = "" + node_msg = "" if classes.count > 1 class_msg = "#{classes.count}_classes" else class_msg = classes[0].name.gsub(/::/,'__') end @@ -89,11 +87,12 @@ require 'deep_merge' # This should take an array of tests and remove any duplicates from them # this will be an array of arrays, or maybe hashes combinations = [] - new_tests = [] + new_tests = [] + tests.each do |test| test.nodes.each do |node| test.classes.each do |cls| combo = {node => cls} if combinations.member?(combo) @@ -102,19 +101,19 @@ relevant_test = new_tests[new_tests.index do |a| a.nodes[0] == node and a.classes[0] == cls end] # Delete all default values in the current options hash - test.test_config.delete_if do |key,value| + test.test_config.delete_if do |key, value| test.default_test_config[key] == value end # Merge the non-default options right on in there relevant_test.test_config.deep_merge!(test.test_config) else combinations << combo - new_tests << Onceover::Test.new(node,cls,test.test_config) + new_tests << Onceover::Test.new(node, cls, test.test_config) end end end end @@ -122,10 +121,10 @@ # represent anything defined in a controlrepo and should just # be passed into the thing doing the testing and then killed, # we don't want too many copies of the same shit going around # # Actually based on the way things are written I don't think this - # will duplicated node or class objects, just test objects, + # will deduplicate node or class objects, just test objects, # everything else is passed by reference new_tests end def self.all