spec/support/change_streams.rb in mongo-2.11.0.rc0 vs spec/support/change_streams.rb in mongo-2.11.0
- old
+ new
@@ -35,21 +35,16 @@
# @since 2.6.0
attr_reader :description
# Instantiate the new spec.
#
- # @example Create the spec.
- # Spec.new(file)
+ # @param [ String ] test_path The path to the file.
#
- # @param [ String ] file The name of the file.
- #
# @since 2.6.0
- def initialize(file)
- file = File.new(file)
- @spec = YAML.load(ERB.new(file.read).result)
- file.close
- @description = File.basename(file)
+ def initialize(test_path)
+ @spec = YAML.load(File.read(test_path))
+ @description = File.basename(test_path)
@spec_tests = @spec['tests']
@coll1 = @spec['collection_name']
@coll2 = @spec['collection2_name']
@db1 = @spec['database_name']
@db2 = @spec['database2_name']
@@ -127,11 +122,11 @@
end
end
def run
change_stream = begin
- @target.watch(@pipeline, @options)
+ @target.watch(@pipeline, Utils.snakeize_hash(@options))
rescue Mongo::Error::OperationFailure => e
return {
result: { 'error' => { 'code' => e.code } },
events: events
}
@@ -193,12 +188,14 @@
lower_bound_satisfied?(client) && upper_bound_satisfied?(client)
end
private
+ IGNORE_COMMANDS = %w(saslStart saslContinue killCursors getMore)
+
def events
EventSubscriber.started_events.reduce([]) do |evs, e|
- next evs if %w(saslStart saslContinue killCursors).include?(e.command_name)
+ next evs if IGNORE_COMMANDS.include?(e.command_name)
evs << {
'command_started_event' => {
'command' => e.command,
'command_name' => e.command_name.to_s,