Sha256: df28751875d59536048db2a44e731d1ce7871b3a5194187b13ef2b64cc6ba651

Contents?: true

Size: 1012 Bytes

Versions: 31

Compression:

Stored size: 1012 Bytes

Contents

require 'active_record'

module SpecCondition
  class << self
    def postgresql?
      ENV['POSTGRESQL'] == '1'
    end

    def mysql57?
      ENV['MYSQL57'] == '1'
    end

    def mysql_awesome_enabled?
      ENV['ENABLE_MYSQL_AWESOME'] == '1'
    end

    def activerecord_5?
      ActiveRecord::VERSION::MAJOR >= 5 and ActiveRecord::VERSION::MAJOR < 6
    end

    def debug?
      ENV['DEBUG'] == '1'
    end
  end

  def check_version_or_cond(version_or_cond)
    case version_or_cond
    when Regexp
      ActiveRecord::VERSION::STRING =~ version_or_cond
    when Float
      ActiveRecord::VERSION::STRING.start_with?(version_or_cond.to_s)
    when String
      ActiveRecord::VERSION::STRING.start_with?(version_or_cond)
    else
      SpecCondition.send("#{version_or_cond}?")
    end
  end

  def condition(*conds)
    conds.any? do |c|
      if c.is_a? Array
        c.all? {|i| check_version_or_cond(i) }
      else
        check_version_or_cond(c)
      end
    end
  end
end
include SpecCondition

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ridgepole-0.7.1 spec/spec_condition.rb
ridgepole-0.7.1.beta5 spec/spec_condition.rb
ridgepole-0.7.1.beta4 spec/spec_condition.rb
ridgepole-0.7.1.beta3 spec/spec_condition.rb
ridgepole-0.7.1.beta2 spec/spec_condition.rb
ridgepole-0.7.1.beta spec/spec_condition.rb
ridgepole-0.7.0 spec/spec_condition.rb
ridgepole-0.7.0.rc1 spec/spec_condition.rb
ridgepole-0.7.0.beta22 spec/spec_condition.rb
ridgepole-0.7.0.beta21 spec/spec_condition.rb
ridgepole-0.7.0.beta20 spec/spec_condition.rb
ridgepole-0.7.0.beta19 spec/spec_condition.rb
ridgepole-0.7.0.beta18 spec/spec_condition.rb
ridgepole-0.7.0.beta17 spec/spec_condition.rb
ridgepole-0.7.0.beta16 spec/spec_condition.rb
ridgepole-0.7.0.beta15 spec/spec_condition.rb
ridgepole-0.7.0.beta14 spec/spec_condition.rb
ridgepole-0.7.0.beta13 spec/spec_condition.rb
ridgepole-0.7.0.beta12 spec/spec_condition.rb
ridgepole-0.7.0.beta11 spec/spec_condition.rb