spec/support/crud.rb in mongo-2.5.3 vs spec/support/crud.rb in mongo-2.6.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2014-2017 MongoDB, Inc. +# Copyright (C) 2014-2018 MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -123,11 +123,12 @@ # @return [ String ] description The test description. # # @since 2.0.0 attr_reader :description - FAIL_POINT_BASE_COMMAND = { configureFailPoint: "onPrimaryTransactionalWrite" } + # Spec tests have configureFailPoint as a string, make it a string here too + FAIL_POINT_BASE_COMMAND = { 'configureFailPoint' => "onPrimaryTransactionalWrite" } # Instantiate the new CRUDTest. # # @example Create the test. # CRUDTest.new(data, test) @@ -137,11 +138,13 @@ # @param [ Hash ] test The test specification. # # @since 2.0.0 def initialize(data, test) @data = data - @fail_point_command = FAIL_POINT_BASE_COMMAND.merge(test['failPoint']) if test['failPoint'] + if test['failPoint'] + @fail_point_command = FAIL_POINT_BASE_COMMAND.merge(test['failPoint']) + end @description = test['description'] @operation = Operation.get(test['operation']) @outcome = test['outcome'] end @@ -167,10 +170,12 @@ collection.insert_many(@data) set_up_fail_point(collection) end def set_up_fail_point(collection) - collection.client.use(:admin).command(@fail_point_command) if @fail_point_command + if @fail_point_command + collection.client.use(:admin).command(@fail_point_command) + end end def clear_fail_point(collection) if @fail_point_command collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(mode: "off"))