Sha256: b411b5e8c0b2a39591ebf747ff6ae80cd1a5189ddc6580f4145c1bb1505271a4

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
require 'rails'

def unit_example?(example)
  path = example.metadata[:example_group][:file_path]
  path =~ /spec\/unit/
end

def rails4?
  ::Rails::VERSION::STRING >= '4'
end

RSpec.configure do |config|
  config.before(:each) do
    Modis.with_connection do |redis|
      redis.keys('rpush:*').each { |key| redis.del(key) }
    end

    if unit_example?(example)
      connection = ActiveRecord::Base.connection

      if rails4?
        connection.begin_transaction joinable: false
      else
        connection.increment_open_transactions
        connection.transaction_joinable = false
        connection.begin_db_transaction
      end
    end
  end

  config.after(:each) do
    if unit_example?(example)
      connection = ActiveRecord::Base.connection

      if rails4?
        connection.rollback_transaction if connection.transaction_open?
      else
        if connection.open_transactions != 0
          connection.rollback_db_transaction
          connection.decrement_open_transactions
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rpush-2.3.1-java spec/unit_spec_helper.rb
rpush-2.3.1 spec/unit_spec_helper.rb
rpush-2.3.0-java spec/unit_spec_helper.rb
rpush-2.3.0 spec/unit_spec_helper.rb
rpush-2.3.0.rc1 spec/unit_spec_helper.rb
rpush-2.2.0-java spec/unit_spec_helper.rb
rpush-2.2.0 spec/unit_spec_helper.rb
rpush-2.1.0-java spec/unit_spec_helper.rb
rpush-2.1.0 spec/unit_spec_helper.rb
rpush-2.0.1-java spec/unit_spec_helper.rb
rpush-2.0.1 spec/unit_spec_helper.rb
rpush-2.0.0-java spec/unit_spec_helper.rb
rpush-2.0.0 spec/unit_spec_helper.rb
rpush-2.0.0.rc1-java spec/unit_spec_helper.rb
rpush-2.0.0.rc1 spec/unit_spec_helper.rb
rpush-2.0.0.beta2 spec/unit_spec_helper.rb
rpush-2.0.0.beta1 spec/unit_spec_helper.rb