Class: Crucible::Tests::SuiteEngine
- Inherits:
-
Object
- Object
- Crucible::Tests::SuiteEngine
- Defined in:
- lib/tests/suites/suite_engine.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_suites_map ⇒ Object
-
#find_test(key) ⇒ Object
Use the built test suites to find a given test suite.
-
#initialize(client = nil, client2 = nil) ⇒ SuiteEngine
constructor
A new instance of SuiteEngine.
- #metadata(test) ⇒ Object
- #metadata_all ⇒ Object
-
#tests ⇒ Object
Build all the test suites if none exist, but only reference the class.
Constructor Details
#initialize(client = nil, client2 = nil) ⇒ SuiteEngine
Returns a new instance of SuiteEngine.
5 6 7 8 9 |
# File 'lib/tests/suites/suite_engine.rb', line 5 def initialize(client=nil, client2=nil) @client = client @client2 = client2 build_suites_map end |
Class Method Details
.generate_metadata ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/tests/suites/suite_engine.rb', line 78 def self. = {} puts "---" puts "BUILDING METADATA" puts "---" SuiteEngine.new.tests.each do |test| test_file = Crucible::Tests.const_get(test).new(nil) if test_file.respond_to? 'resource_class=' Crucible::Tests::BaseSuite.fhir_resources.each do |klass| test_file.resource_class = Module.const_get("FHIR::#{klass}") puts "---" puts "BUILDING METADATA - #{test}#{klass}" puts "---" ["#{test}#{klass}"] = test_file.(true) end else puts "---" puts "BUILDING METADATA - #{test}" puts "---" [test] = test_file.(true) end end puts "---" puts "FINISHED METADATA" puts "---" end |
.list_all(metadata = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tests/suites/suite_engine.rb', line 23 def self.list_all(=false) list = {} # FIXME: Organize defaults between instance & class methods SuiteEngine.new.tests.each do |test| test_class = test.class.name.demodulize #if t can set class if test.respond_to? 'resource_class=' Crucible::Tests::BaseSuite.fhir_resources.each do |klass| test.resource_class = Module.const_get("FHIR::#{klass}") list["#{test_class}#{klass}"] = {} list["#{test_class}#{klass}"]['resource_class'] = klass BaseTest::JSON_FIELDS.each {|field| list["#{test_class}#{klass}"][field] = test.send(field)} if = test.(true) BaseTest::METADATA_FIELDS.each do |field| field_hash = {} .each { |tm| field_hash[tm[:test_method]] = tm[field] } list["#{test_class}#{klass}"][field] = field_hash end end end else list[test.title] = {} BaseTest::JSON_FIELDS.each {|field| list[test.title][field] = test.send(field)} if = test.(true) BaseTest::METADATA_FIELDS.each do |field| field_hash = {} .each { |tm| field_hash[tm[:test_method]] = tm[field] } list[test.title][field] = field_hash end end end end list end |
Instance Method Details
#build_suites_map ⇒ Object
71 72 73 74 75 76 |
# File 'lib/tests/suites/suite_engine.rb', line 71 def build_suites_map @suites = {} (Crucible::Tests.constants.grep(/Test$/) - [:BaseTest]).each do |suite| @suites[suite] = Crucible::Tests.const_get(suite) end end |
#find_test(key) ⇒ Object
Use the built test suites to find a given test suite
67 68 69 |
# File 'lib/tests/suites/suite_engine.rb', line 67 def find_test(key) @suites[key.to_sym].new(@client, @client2) if @suites.keys.include?(key.to_sym) end |
#metadata(test) ⇒ Object
11 12 13 |
# File 'lib/tests/suites/suite_engine.rb', line 11 def (test) Crucible::Tests.const_get(test).new(@client). end |
#metadata_all ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/tests/suites/suite_engine.rb', line 15 def results = [] tests.each do |test| results = results.concat (test) end results end |
#tests ⇒ Object
Build all the test suites if none exist, but only reference the class
61 62 63 64 |
# File 'lib/tests/suites/suite_engine.rb', line 61 def tests # return newly-initialized copies of the tests @suites.values.map {|suite| suite.new(@client, @client2)} end |