Sha256: 01668efbcab8d8ad8972a603fb932da51f39b5638b47c520d68c94be700a8563
Contents?: true
Size: 1.84 KB
Versions: 7
Compression:
Stored size: 1.84 KB
Contents
# frozen_string_literal: true # encoding: utf-8 module Mongo module CRUD # Represents a CRUD specification test. class Spec # Instantiate the new spec. # # @param [ String ] test_path The path to the file. # # @since 2.0.0 def initialize(test_path) @spec = ::Utils.load_spec_yaml_file(test_path) @description = File.basename(test_path) @data = BSON::ExtJSON.parse_obj(@spec['data']) @tests = @spec['tests'] # Introduced with Client-Side Encryption tests @json_schema = BSON::ExtJSON.parse_obj(@spec['json_schema']) @key_vault_data = BSON::ExtJSON.parse_obj(@spec['key_vault_data']) @requirements = if run_on = @spec['runOn'] run_on.map do |spec| Requirement.new(spec) end elsif Requirement::YAML_KEYS.any? { |key| @spec.key?(key) } [Requirement.new(@spec)] else nil end end # @return [ String ] description The spec description. # # @since 2.0.0 attr_reader :description attr_reader :requirements # @return [ Hash ] The jsonSchema collection validator. attr_reader :json_schema # @return [ Array<Hash> ] Data to insert into the key vault before # running each test. attr_reader :key_vault_data def collection_name # Older spec tests do not specify a collection name, thus # we provide a default here @spec['collection_name'] || 'crud_spec_test' end def bucket_name @spec['bucket_name'] end def database_name @spec['database_name'] end # Get a list of Test instances, one for each test definition. def tests @tests.map do |test| Mongo::CRUD::CRUDTest.new(self, @data, test) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems