Sha256: c8e6c8f8062a0fcad92a4a373443b9736f7ba228211c505caf5655170695bb82
Contents?: true
Size: 1.81 KB
Versions: 9
Compression:
Stored size: 1.81 KB
Contents
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) contents = File.read(test_path) @spec = YAML.load(contents) @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
9 entries across 9 versions & 1 rubygems