Sha256: e57148958453f41a7ea8fc831f0a582160aea1a893651139c49fb0995a07263a

Contents?: true

Size: 1.99 KB

Versions: 6

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe 'Transactions API' do

  TRANSACTIONS_API_TESTS.sort.each do |file|

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

    context(spec.description) do
      define_spec_tests_with_requirements(spec) do |req|
        spec.tests.each do |test_factory|
          test_instance = test_factory.call

          context(test_instance.description) do

            let(:test) { test_factory.call }

            if test_instance.skip_reason
              before do
                skip test_instance.skip_reason
              end
            end

            before(:each) do
              if req.satisfied?
                test.setup_test
              end
            end

            after(:each) do
              if req.satisfied?
                test.teardown_test
              end
            end

            let(:results) do
              test.run
            end

            let(:verifier) { Mongo::CRUD::Verifier.new(test) }

            it 'returns the correct result' do
              verifier.verify_operation_result(test_instance.expected_results, results[:results])
            end

            it 'has the correct data in the collection', if: test_instance.outcome.collection_data? do
              results
              verifier.verify_collection_data(
                test_instance.outcome.collection_data,
                results[:contents])
            end

            if test_instance.expectations
              it 'has the correct number of command_started events' do
                verifier.verify_command_started_event_count(
                  test_instance.expectations, results[:events])
              end

              test_instance.expectations.each_with_index do |expectation, i|
                it "has the correct command_started event #{i}" do
                  verifier.verify_command_started_event(
                    test_instance.expectations, results[:events], i)
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongo-2.9.2 spec/spec_tests/transactions_api_spec.rb
mongo-2.9.1 spec/spec_tests/transactions_api_spec.rb
mongo-2.9.1.rc0 spec/spec_tests/transactions_api_spec.rb
mongo-2.9.0 spec/spec_tests/transactions_api_spec.rb
mongo-2.9.0.rc1 spec/spec_tests/transactions_api_spec.rb
mongo-2.9.0.rc0 spec/spec_tests/transactions_api_spec.rb