2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "active_support/test_case"
|
|
|
|
require "active_support/testing/autorun"
|
|
|
|
require "rails/generators/app_base"
|
2013-10-31 14:48:12 -04:00
|
|
|
|
|
|
|
module Rails
|
|
|
|
module Generators
|
|
|
|
class GeneratorTest < ActiveSupport::TestCase
|
|
|
|
def make_builder_class
|
2013-11-01 06:11:52 -04:00
|
|
|
Class.new(AppBase) do
|
2013-10-31 14:48:12 -04:00
|
|
|
add_shared_options_for "application"
|
|
|
|
|
|
|
|
# include a module to get around thor's method_added hook
|
|
|
|
include(Module.new {
|
|
|
|
def gemfile_entries; super; end
|
|
|
|
def invoke_all; super; self; end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_construction
|
2016-10-28 23:05:58 -04:00
|
|
|
klass = make_builder_class
|
2016-08-06 13:16:09 -04:00
|
|
|
assert klass.start(["new", "blah"])
|
2013-10-31 14:48:12 -04:00
|
|
|
end
|
|
|
|
|
2015-12-18 02:32:21 -05:00
|
|
|
def test_recommended_rails_versions
|
|
|
|
klass = make_builder_class
|
2016-08-06 13:16:09 -04:00
|
|
|
generator = klass.start(["new", "blah"])
|
2015-12-18 02:32:21 -05:00
|
|
|
|
|
|
|
specifier_for = -> v { generator.send(:rails_version_specifier, Gem::Version.new(v)) }
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
assert_equal "~> 4.1.13", specifier_for["4.1.13"]
|
2017-01-04 12:43:46 -05:00
|
|
|
assert_equal "~> 4.1.6.rc1", specifier_for["4.1.6.rc1"]
|
2016-08-06 13:16:09 -04:00
|
|
|
assert_equal ["~> 4.1.7", ">= 4.1.7.1"], specifier_for["4.1.7.1"]
|
|
|
|
assert_equal ["~> 4.1.7", ">= 4.1.7.1.2"], specifier_for["4.1.7.1.2"]
|
2017-01-04 12:43:46 -05:00
|
|
|
assert_equal ["~> 4.1.7", ">= 4.1.7.1.rc2"], specifier_for["4.1.7.1.rc2"]
|
|
|
|
assert_equal "~> 4.2.0.beta1", specifier_for["4.2.0.beta1"]
|
|
|
|
assert_equal "~> 5.0.0.beta1", specifier_for["5.0.0.beta1"]
|
2015-12-18 02:32:21 -05:00
|
|
|
end
|
2013-10-31 14:48:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|