Sha256: 264dd17aed95f855bbcb8fd23e5e6d8e8008f2352452c0170bac365e85685a15

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

module Cucumber
  module Rails
    module Database
      class Strategy
        def initialize(options = {})
          @options = options
        end

        def before_js(strategy)
          @original_strategy = if defined?(DatabaseCleaner::VERSION) && Gem::Version.new(DatabaseCleaner::VERSION) >= Gem::Version.new('1.8.0.beta')
                                 DatabaseCleaner.cleaners.values.first.strategy # that feels like a nasty hack
                               else
                                 DatabaseCleaner.connections.first.strategy # that feels like a nasty hack
                               end
          DatabaseCleaner.strategy = strategy, @options
        end

        def before_non_js
          # no-op
        end

        def after
          return unless @original_strategy

          DatabaseCleaner.strategy = @original_strategy
          @original_strategy = nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-rails-2.3.0 lib/cucumber/rails/database/strategy.rb