Skip to content

Commit 02a5be2

Browse files
committed
Fix rails version selection
Previous code wasn't working correctly
1 parent a072c15 commit 02a5be2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/acceptance/helper.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def controller_tests_dir
2323
end
2424

2525
def bundles_spring?
26-
version >= Gem::Version.new("4.1.0.beta1")
26+
version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
2727
end
2828

2929
def major
@@ -33,6 +33,10 @@ def major
3333
def minor
3434
version.segments[1]
3535
end
36+
37+
def to_s
38+
version.to_s
39+
end
3640
end
3741

3842
class Application
@@ -270,12 +274,12 @@ def generate
270274
system("gem list rails --installed --version '#{version_constraint}' || " \
271275
"gem install rails --clear-sources --source http://rubygems.org --version '#{version_constraint}'")
272276

277+
@version = RailsVersion.new(`ruby -e 'puts Gem::Specification.find_by_name("rails", "#{version_constraint}").version'`.chomp)
278+
273279
skips = %w(--skip-bundle --skip-javascript --skip-sprockets)
274280
skips << "--skip-spring" if version.bundles_spring?
275281

276-
rails = `ruby -e 'puts Gem.bin_path("railties", "rails", "#{version_constraint}")'`.chomp
277-
system("#{rails} new #{application.root} #{skips.join(' ')}")
278-
282+
system("rails _#{version}_ new #{application.root} #{skips.join(' ')}")
279283
raise "application generation failed" unless application.exists?
280284

281285
FileUtils.mkdir_p(application.gem_home)

0 commit comments

Comments
 (0)