diff options
author | Terence Lee <hone02@gmail.com> | 2013-08-19 19:36:09 -0700 |
---|---|---|
committer | Terence Lee <hone02@gmail.com> | 2013-08-24 15:15:28 -0700 |
commit | e1ff1b281e4fe9932e6ff127f756f5acb03968ec (patch) | |
tree | b2fd581e221c015521d3794ee622d693d00211fd /spec | |
parent | 47964a138d964af49e0834806a9ef7930f322d0c (diff) | |
download | bundler-e1ff1b281e4fe9932e6ff127f756f5acb03968ec.tar.gz |
patchlevel support for ruby DSL
Diffstat (limited to 'spec')
-rw-r--r-- | spec/other/bundle_ruby_spec.rb | 180 | ||||
-rw-r--r-- | spec/other/platform_spec.rb | 200 | ||||
-rw-r--r-- | spec/support/platforms.rb | 4 |
3 files changed, 309 insertions, 75 deletions
diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb index 5bb563a7..7d41a00d 100644 --- a/spec/other/bundle_ruby_spec.rb +++ b/spec/other/bundle_ruby_spec.rb @@ -1,112 +1,142 @@ require "spec_helper" describe "bundle_ruby" do - it "returns the ruby version" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3' + context "without patchlevel" do + it "returns the ruby version" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3' - gem "foo" - G + gem "foo" + G - bundle_ruby + bundle_ruby - expect(out).to eq("ruby 1.9.3") - end + expect(out).to eq("ruby 1.9.3") + end - it "engine defaults to MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3" + it "engine defaults to MRI" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.9.3" - gem "foo" - G + gem "foo" + G - bundle_ruby + bundle_ruby - expect(out).to eq("ruby 1.9.3") - end + expect(out).to eq("ruby 1.9.3") + end - it "handles jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5' + it "handles jruby" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5' - gem "foo" - G + gem "foo" + G - bundle_ruby + bundle_ruby - expect(out).to eq("ruby 1.8.7 (jruby 1.6.5)") - end + expect(out).to eq("ruby 1.8.7 (jruby 1.6.5)") + end - it "handles rbx" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4' + it "handles rbx" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4' - gem "foo" - G + gem "foo" + G - bundle_ruby + bundle_ruby - expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)") - end + expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)") + end - it "raises an error if engine is used but engine version is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx' + it "raises an error if engine is used but engine version is not" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.8.7", :engine => 'rbx' - gem "foo" - G + gem "foo" + G - bundle_ruby :exitstatus => true - expect(exitstatus).not_to eq(0) + bundle_ruby :exitstatus => true + expect(exitstatus).not_to eq(0) - bundle_ruby - expect(out).to eq("Please define :engine_version") - end + bundle_ruby + expect(out).to eq("Please define :engine_version") + end - it "raises an error if engine_version is used but engine is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine_version => '1.2.4' + it "raises an error if engine_version is used but engine is not" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.8.7", :engine_version => '1.2.4' - gem "foo" - G + gem "foo" + G - bundle_ruby :exitstatus => true - expect(exitstatus).not_to eq(0) + bundle_ruby :exitstatus => true + expect(exitstatus).not_to eq(0) - bundle_ruby - expect(out).to eq("Please define :engine") - end + bundle_ruby + expect(out).to eq("Please define :engine") + end + + it "raises an error if engine version doesn't match ruby version for MRI" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4' - it "raises an error if engine version doesn't match ruby version for MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4' + gem "foo" + G - gem "foo" - G + bundle_ruby :exitstatus => true + expect(exitstatus).not_to eq(0) - bundle_ruby :exitstatus => true - expect(exitstatus).not_to eq(0) + bundle_ruby + expect(out).to eq("ruby_version must match the :engine_version for MRI") + end - bundle_ruby - expect(out).to eq("ruby_version must match the :engine_version for MRI") + it "should print if no ruby version is specified" do + gemfile <<-G + source "file://#{gem_repo1}" + + gem "foo" + G + + bundle_ruby + + expect(out).to eq("No ruby version specified") + end end - it "should print if no ruby version is specified" do - gemfile <<-G - source "file://#{gem_repo1}" + context "when using patchlevel" do + it "returns the ruby version" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.9.3", :patchlevel => 429, :engine => 'ruby', :engine_version => '1.9.3' + + gem "foo" + G + + bundle_ruby + + expect(out).to eq("ruby 1.9.3p429") + end + + it "handles an engine" do + gemfile <<-G + source "file://#{gem_repo1}" + ruby "1.9.3", :patchlevel => 392, :engine => 'jruby', :engine_version => '1.7.4' - gem "foo" - G + gem "foo" + G - bundle_ruby + bundle_ruby - expect(out).to eq("No ruby version specified") + expect(out).to eq("ruby 1.9.3p392 (jruby 1.7.4)") + end end end diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index 127bf904..a4832187 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -25,6 +25,29 @@ Your current platform satisfies the Ruby version requirement. G end + it "returns all the output including the patchlevel" do + gemfile <<-G + source "file://#{gem_repo1}" + + #{ruby_version_correct_patchlevel} + + gem "foo" + G + + bundle "platform" + expect(out).to eq(<<-G.chomp) +Your platform is: #{RUBY_PLATFORM} + +Your app has gems that work on these platforms: +* ruby + +Your Gemfile specifies a Ruby version requirement: +* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} + +Your current platform satisfies the Ruby version requirement. +G + end + it "doesn't print ruby version requirement if it isn't specified" do gemfile <<-G source "file://#{gem_repo1}" @@ -175,9 +198,11 @@ G let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" } let(:ruby_version_correct_engineless) { "ruby \"#{RUBY_VERSION}\"" } + let(:ruby_version_correct_patchlevel) { "#{ruby_version_correct}, :patchlevel => #{RUBY_PATCHLEVEL}" } let(:ruby_version_incorrect) { "ruby \"#{not_local_ruby_version}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_ruby_version}\"" } let(:engine_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{not_local_tag}\", :engine_version => \"#{RUBY_VERSION}\"" } let(:engine_version_incorrect) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{not_local_engine_version}\"" } + let(:patchlevel_incorrect) { "#{ruby_version_correct}, :patchlevel => #{not_local_patchlevel}" } def should_be_ruby_version_incorrect(opts = {:exitstatus => true}) expect(exitstatus).to eq(18) if opts[:exitstatus] @@ -194,6 +219,12 @@ G expect(out).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}") end + def should_be_patchlevel_incorrect(opts = {:exitstatus => true}) + expect(exitstatus).to eq(18) if opts[:exitstatus] + + expect(out).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}") + end + context "bundle install" do it "installs fine when the ruby version matches" do install_gemfile <<-G @@ -219,6 +250,17 @@ G end end + it "installs fine when the patchlevel matches" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + + #{ruby_version_correct_patchlevel} + G + + expect(bundled_app('Gemfile.lock')).to exist + end + it "doesn't install when the ruby version doesn't match" do install_gemfile <<-G, :exitstatus => true source "file://#{gem_repo1}" @@ -256,6 +298,18 @@ G should_be_engine_version_incorrect end end + + it "doesn't install when patchlevel doesn't match" do + install_gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + + expect(bundled_app('Gemfile.lock')).not_to exist + should_be_patchlevel_incorrect + end end context "bundle check" do @@ -349,6 +403,23 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + install_gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + G + + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + + bundle :check, :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle update" do @@ -445,6 +516,21 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + update_repo2 do + build_gem "activesupport", "3.0" + end + + bundle :update, :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle show" do @@ -518,6 +604,21 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + update_repo2 do + build_gem "activesupport", "3.0" + end + + bundle "show rails", :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle cache" do @@ -587,6 +688,18 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + + bundle :cache, :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle pack" do @@ -656,6 +769,18 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + + bundle :pack, :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle exec" do @@ -721,6 +846,18 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + + #{patchlevel_incorrect} + G + + bundle "exec rackup", :exitstatus => true + should_be_patchlevel_incorrect + end end context "bundle console" do @@ -812,6 +949,20 @@ G should_be_engine_version_incorrect end end + + it "fails when patchlevel doesn't match" do + gemfile <<-G, :exitstatus => true + source "file://#{gem_repo1}" + gem "rack" + gem "activesupport", :group => :test + gem "rack_middleware", :group => :development + + #{patchlevel_incorrect} + G + + bundle "console", :exitstatus => true + should_be_patchlevel_incorrect + end end context "Bundler.setup" do @@ -944,6 +1095,35 @@ G should_be_engine_version_incorrect(:exitstatus => false) end end + + it "fails when patchlevel doesn't match" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "yard" + gem "rack" + + #{patchlevel_incorrect} + G + + puts File.read(bundled_app("Gemfile")) + File.read(bundled_app("Gemfile.lock")) + + FileUtils.rm(bundled_app("Gemfile.lock")) + + ruby <<-R + require 'rubygems' + require 'bundler' + + begin + Bundler.setup + rescue Bundler::RubyVersionMismatch => e + puts e.message + end + R + + expect(bundled_app("Gemfile.lock")).not_to exist + should_be_patchlevel_incorrect(:exitstatus => false) + end end context "bundle outdated" do @@ -1054,5 +1234,25 @@ G should_be_engine_version_incorrect end end + + it "fails when the patchlevel doesn't match" do + simulate_ruby_engine "jruby" do + update_repo2 do + build_gem "activesupport", "3.0" + update_git "foo", :path => lib_path("foo") + end + + gemfile <<-G + source "file://#{gem_repo2}" + gem "activesupport", "2.3.5" + gem "foo", :git => "#{lib_path('foo')}" + + #{patchlevel_incorrect} + G + + bundle "outdated", :exitstatus => true + should_be_patchlevel_incorrect + end + end end end diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb index 7636395d..b574d63c 100644 --- a/spec/support/platforms.rb +++ b/spec/support/platforms.rb @@ -86,5 +86,9 @@ module Spec def not_local_ruby_version "1.12" end + + def not_local_patchlevel + 9999 + end end end |