Sha256: 421905f9f65945d735fef14500be05be445ec19cd7783d74f3187c65320257b8

Contents?: true

Size: 1.1 KB

Versions: 11

Compression:

Stored size: 1.1 KB

Contents

RSpec::Matchers.define :be_int32 do |num|
  match do |actual|
    actual == [num].pack('l<')
  end
end

RSpec::Matchers.define :be_int64 do |num|
  match do |actual|
    actual == [num].pack('q<')
  end
end

RSpec::Matchers.define :be_int64_sequence do |array|
  match do |actual|
    actual == array.reduce(String.new) do |buffer, num|
      buffer << [num].pack('q<')
    end
  end
end

RSpec::Matchers.define :be_cstring do |string|
  match do |actual|
    actual == "#{string.force_encoding(BSON::BINARY)}\0"
  end
end

RSpec::Matchers.define :be_bson do |hash|
  match do |actual|
    actual == hash.to_bson.to_s
  end
end

RSpec::Matchers.define :be_bson_sequence do |array|
  match do |actual|
    actual == array.map(&:to_bson).join
  end
end

RSpec::Matchers.define :be_ciphertext do
  match do |object|
    object.is_a?(BSON::Binary) && object.type == :ciphertext
  end
end


RSpec::Matchers.define :match_with_type do |event|
  match do |actual|
    Utils.match_with_type?(event, actual)
  end
end

RSpec::Matchers.define :be_uuid do
  match do |object|
    object.is_a?(BSON::Binary) && object.type == :uuid
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/support/matchers.rb
mongo-2.13.2 spec/support/matchers.rb
mongo-2.13.1 spec/support/matchers.rb
mongo-2.12.4 spec/support/matchers.rb
mongo-2.13.0 spec/support/matchers.rb
mongo-2.12.3 spec/support/matchers.rb
mongo-2.13.0.rc1 spec/support/matchers.rb
mongo-2.12.2 spec/support/matchers.rb
mongo-2.13.0.beta1 spec/support/matchers.rb
mongo-2.12.1 spec/support/matchers.rb
mongo-2.12.0.rc0 spec/support/matchers.rb