Sha256: 75576e3b524c912df679a7996d93ca004b07479ad97bff8ee3e56d33f78bf9aa

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe With::Version::Ruby do
  include With::Version::Ruby

  NEXT_VERSION = Gem::Version.new(RUBY_VERSION).bump.to_s
  PREV_VERSION = Gem::Version.new('1.9.3').to_s

  context '#with_minimum_ruby' do
    before :all do
      @versions = []
    end

    context NEXT_VERSION do
      with_minimum_ruby(NEXT_VERSION) do
        it 'never runs' do
          raise NEXT_VERSION
        end
      end
    end

    context RUBY_VERSION do
      with_minimum_ruby(RUBY_VERSION) do
        it 'includes the current version' do
          @versions << RUBY_VERSION
        end
      end
    end

    context PREV_VERSION do
      with_minimum_ruby(PREV_VERSION) do
        it 'includes the current version' do
          @versions << PREV_VERSION
        end
      end
    end

    after :all do
      expect(@versions.sort).to eq([PREV_VERSION, RUBY_VERSION])
    end
  end

  RELEASE_VERSION = Gem::Version.new(RUBY_VERSION).release.to_s
  PRE_RELEASE_VERSION = Gem::Version.new(RELEASE_VERSION + '.pre1').to_s

  context PRE_RELEASE_VERSION do
    it 'includes includes pre-release' do
      extend With::Version::Ruby::ClassMethods
      stub_const('RUBY_VERSION', PRE_RELEASE_VERSION)
      version_included = nil
      with_minimum_ruby(RELEASE_VERSION) do
        version_included = RUBY_VERSION
      end
      expect(version_included).to eq PRE_RELEASE_VERSION
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
with-version-0.2.0 spec/with-version/ruby_spec.rb