1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/version_test.rb
Prem Sichanugrist 2dd2fcf896
Introduce Rails.gem_version
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05:00

12 lines
335 B
Ruby

require 'abstract_unit'
class VersionTest < ActiveSupport::TestCase
def test_rails_version_returns_a_string
assert Rails.version.is_a? String
end
def test_rails_gem_version_returns_a_correct_gem_version_object
assert Rails.gem_version.is_a? Gem::Version
assert_equal Rails.version, Rails.gem_version.to_s
end
end