Class: Crucible::Tests::TestScriptEngine
- Inherits:
-
Object
- Object
- Crucible::Tests::TestScriptEngine
- Defined in:
- lib/tests/testscripts/testscript_engine.rb
Constant Summary collapse
- @@models =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #execute_all ⇒ Object
- #find_test(key) ⇒ Object
-
#initialize(client = nil, client2 = nil) ⇒ TestScriptEngine
constructor
A new instance of TestScriptEngine.
- #load_testscripts ⇒ Object
- #tests ⇒ Object
Constructor Details
#initialize(client = nil, client2 = nil) ⇒ TestScriptEngine
Returns a new instance of TestScriptEngine.
7 8 9 10 11 12 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 7 def initialize(client=nil, client2=nil) @client = client @client2 = client2 @scripts = [] load_testscripts end |
Class Method Details
.list_all(metadata = false) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 40 def self.list_all(=false) list = {} # TODO: Determine if we need resource-based testscript listing support TestScriptEngine.new.tests.each do |test| 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 = {} .values.first.each { |tm| field_hash[tm[:test_method]] = tm[field] } list[test.title][field] = field_hash end end end list end |
.parse_testscripts ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 65 def self.parse_testscripts return unless @@models.empty? # get all specification example TestScripts root = File. '.', File.dirname(File.absolute_path(__FILE__)) path = File.join(root, 'scripts', 'spec', '**/*.xml') script_files = Dir.glob(path) # get all the Connectathon TestScripts path = File.join(root, 'scripts', 'connectathon', '**/*.xml') script_files += Dir.glob(path) script_files.each do |f| begin script = FHIR.from_contents( File.read(f) ) if script.is_a?(FHIR::TestScript) && script.is_valid? script.url = f # replace the URL with the local file path so file system references can properly resolve @@models << script FHIR.logger.info "TestScriptEngine.parse_testscripts: Loaded #{f}" elsif script.is_a?(FHIR::TestScript) FHIR.logger.error "TestScriptEngine.parse_testscripts: Skipping invalid TestScript #{f}" else # this is a fixture... FHIR.logger.warn "TestScriptEngine.parse_testscripts: Skipping fixture #{f}" end rescue FHIR.logger.error "TestScriptEngine.parse_testscripts: Exception deserializing TestScript #{f}" end end end |
Instance Method Details
#execute_all ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 22 def execute_all results = {} self.tests.each do |test| if test.multiserver puts "Skipping Multiserver TestScript: #{test.id}" FHIR.logger.info "Skipping Multiserver TestScript: #{test.id}" elsif test.containsRuleAssertions? puts "Skipping TestScript with permanently-unsupported Rule/RuleSet Assertions: #{test.id}" FHIR.logger.info "Skipping TestScript with permanently-unsupported Rule/RuleSet Assertions: #{test.id}" else puts "Executing: #{test.id}" FHIR.logger.info "Executing: #{test.id}" results.merge! test.execute end end results end |
#find_test(key) ⇒ Object
18 19 20 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 18 def find_test(key) @scripts.find{|s| s.id == key || s.title == key} end |
#load_testscripts ⇒ Object
58 59 60 61 62 63 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 58 def load_testscripts return unless @scripts.empty? @@models.each do |model| @scripts << BaseTestScript.new(model, @client, @client2) end end |
#tests ⇒ Object
14 15 16 |
# File 'lib/tests/testscripts/testscript_engine.rb', line 14 def tests @scripts end |