Sha256: b423f4c7187aa1e8f7dece723567ca263a32d515b939427b480a5f0f1a733c42

Contents?: true

Size: 1.64 KB

Versions: 18

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'
require 'database_cleaner/sequel/deletion'
require 'database_cleaner/shared_strategy'
require 'sequel'
require 'support/active_record/database_setup'

module DatabaseCleaner
  module Sequel
    describe Deletion do
      it_should_behave_like "a generic strategy"
    end

    shared_examples 'a Sequel deletion strategy' do
      let(:deletion) do
        d = Deletion.new
        d.db = db
        d
      end

      context 'when several tables have data' do
        before(:each) do
          db.create_table!(:precious_stones) { primary_key :id }
          db.create_table!(:replaceable_trifles)  { primary_key :id }
          db.create_table!(:worthless_junk)  { primary_key :id }

          db[:precious_stones].insert
          db[:replaceable_trifles].insert
          db[:worthless_junk].insert
        end

        context 'by default' do
          it 'deletes all the tables' do
            d = Deletion.new
            d.db = db
            d.clean

            expect(db[:replaceable_trifles]).to have(0).rows
            expect(db[:worthless_junk]).to have(0).rows
            expect(db[:precious_stones]).to have(0).rows
          end
        end
      end
    end

    supported_configurations = [
      { :url => 'mysql:///', :connection_options => db_config['mysql'] },
      { :url => 'postgres:///', :connection_options => db_config['postgres'] }
    ]

    supported_configurations.each do |config|
      describe "Sequel deletion (using a #{config[:url]} connection)" do
        let(:db) { ::Sequel.connect(config[:url], config[:connection_options]) }

        it_behaves_like 'a Sequel deletion strategy'
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
database_cleaner-1.6.2 spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.6.1 spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.6.0 spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.5.3 spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.5.2 spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.5.1 spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.5.0 spec/database_cleaner/sequel/deletion_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/database_cleaner-1.4.1/spec/database_cleaner/sequel/deletion_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/database_cleaner-1.4.1/spec/database_cleaner/sequel/deletion_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/database_cleaner-1.4.1/spec/database_cleaner/sequel/deletion_spec.rb
database_cleaner-1.4.1 spec/database_cleaner/sequel/deletion_spec.rb