Sha256: c8ee1100dbae612f751876dd2508c37c1004a092521f9a4aa7f1bcf889d2cba4

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  describe Rewriter::RubyVersion do
    before do
      allow(File).to receive(:exist?).with('./.ruby-version').and_return(true)
      allow(File).to receive(:read).with('./.ruby-version').and_return('3.0.0')
    end

    it 'returns true if ruby version is greater than 1.9' do
      ruby_version = Rewriter::RubyVersion.new('1.9')
      expect(ruby_version).to be_match
    end

    it 'returns false if ruby version is less than 19.0' do
      ruby_version = Rewriter::RubyVersion.new('19.0')
      expect(ruby_version).not_to be_match
    end

    it 'returns true if strict Configuration is false' do
      Configuration.strict = false
      ruby_version = Rewriter::RubyVersion.new('19.0')
      expect(ruby_version).to be_match
      Configuration.strict = true
    end

    it 'returns true if ruby version is ruby-3.0.0\n' do
      allow(File).to receive(:read).with('./.ruby-version').and_return("ruby-3.0.0\n")
      ruby_version = Rewriter::RubyVersion.new('1.9')
      expect(ruby_version).to be_match
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
synvert-core-2.2.2 spec/synvert/core/rewriter/ruby_version_spec.rb
synvert-core-2.2.1 spec/synvert/core/rewriter/ruby_version_spec.rb
synvert-core-2.2.0 spec/synvert/core/rewriter/ruby_version_spec.rb
synvert-core-2.1.2 spec/synvert/core/rewriter/ruby_version_spec.rb
synvert-core-2.1.1 spec/synvert/core/rewriter/ruby_version_spec.rb