Sha256: 1ff2f130e1309bc34e4acd9d94e43da64450cd7c7a03ab3b9e37bcbc46235dcd

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

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')
                                 raise "No DatabaseCleaner strategies found. Make sure you have required one of DatabaseCleaner's adapters" if DatabaseCleaner.cleaners.empty?

                                 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

9 entries across 9 versions & 1 rubygems

Version Path
cucumber-rails-3.1.0 lib/cucumber/rails/database/strategy.rb
cucumber-rails-3.0.1 lib/cucumber/rails/database/strategy.rb
cucumber-rails-3.0.0 lib/cucumber/rails/database/strategy.rb
cucumber-rails-3.0.0.rc.1 lib/cucumber/rails/database/strategy.rb
cucumber-rails-2.6.1 lib/cucumber/rails/database/strategy.rb
cucumber-rails-2.6.0 lib/cucumber/rails/database/strategy.rb
cucumber-rails-2.5.1 lib/cucumber/rails/database/strategy.rb
cucumber-rails-2.5.0 lib/cucumber/rails/database/strategy.rb
cucumber-rails-2.4.0 lib/cucumber/rails/database/strategy.rb