Sha256: 67cd90ea2998aec86ad58cdb90d65bd8c095c92f6f6b3a49268c82eddab8ea6f

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe 'Transactions' do

  TRANSACTIONS_TESTS.sort.each do |file|

    spec = Mongo::Transactions::Spec.new(file)

    context(spec.description) do
      spec.tests.each do |test|
        context(test.description) do
          require_transaction_support

          before(:each) do
            test.setup_test
          end

          after(:each) do
            test.teardown_test
          end

          let(:results) do
            test.run
          end

          it 'returns the correct result' do
            expect(results[:results]).to match_operation_result(test)
          end

          it 'has the correct data in the collection', if: test.outcome_collection_data do
            expect(results[:contents]).to match_collection_data(test)
          end

          it 'has the correct command_started events', if: test.expectations do
            test.expectations.each do |expectation|
              # We convert the hashes to sorted arrays to ensure that asserting equality between
              # the expected and actual event descriptions don't fail due to the same entries being
              # in a different order.
              expectation['command_started_event']['command'] = expectation['command_started_event']['command'].to_a.sort
              expectation['command_started_event']['command'].delete_if { |_, v| v == nil }
            end

            expect(results[:events]).to eq(test.expectations)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo-2.6.4 spec/spec_tests/transactions_spec.rb
mongo-2.6.2 spec/spec_tests/transactions_spec.rb