diff options
Diffstat (limited to 'spec/bundler/bundler/ruby_version_spec.rb')
-rw-r--r-- | spec/bundler/bundler/ruby_version_spec.rb | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/spec/bundler/bundler/ruby_version_spec.rb b/spec/bundler/bundler/ruby_version_spec.rb index 8c6c071d7f..39d0571361 100644 --- a/spec/bundler/bundler/ruby_version_spec.rb +++ b/spec/bundler/bundler/ruby_version_spec.rb @@ -400,19 +400,19 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do let(:bundler_system_ruby_version) { subject } around do |example| - if Bundler::RubyVersion.instance_variable_defined?("@ruby_version") + if Bundler::RubyVersion.instance_variable_defined?("@system") begin - old_ruby_version = Bundler::RubyVersion.instance_variable_get("@ruby_version") - Bundler::RubyVersion.remove_instance_variable("@ruby_version") + old_ruby_version = Bundler::RubyVersion.instance_variable_get("@system") + Bundler::RubyVersion.remove_instance_variable("@system") example.run ensure - Bundler::RubyVersion.instance_variable_set("@ruby_version", old_ruby_version) + Bundler::RubyVersion.instance_variable_set("@system", old_ruby_version) end else begin example.run ensure - Bundler::RubyVersion.remove_instance_variable("@ruby_version") + Bundler::RubyVersion.remove_instance_variable("@system") end end end @@ -427,9 +427,8 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do end describe "#version" do - it "should return a copy of the value of RUBY_VERSION" do - expect(subject.versions).to eq([RUBY_VERSION]) - expect(subject.versions.first).to_not be(RUBY_VERSION) + it "should return the value of Gem.ruby_version as a string" do + expect(subject.versions).to eq([Gem.ruby_version.to_s]) end end @@ -446,13 +445,12 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do describe "#engine_version" do context "engine is ruby" do before do - stub_const("RUBY_ENGINE_VERSION", "2.2.4") + allow(Gem).to receive(:ruby_version).and_return(Gem::Version.new("2.2.4")) stub_const("RUBY_ENGINE", "ruby") end - it "should return a copy of the value of RUBY_ENGINE_VERSION" do + it "should return the value of Gem.ruby_version as a string" do expect(bundler_system_ruby_version.engine_versions).to eq(["2.2.4"]) - expect(bundler_system_ruby_version.engine_versions.first).to_not be(RUBY_ENGINE_VERSION) end end @@ -498,31 +496,5 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do end end end - - describe "#to_gem_version_with_patchlevel" do - shared_examples_for "the patchlevel is omitted" do - it "does not include a patch level" do - expect(subject.to_gem_version_with_patchlevel.to_s).to eq(version) - end - end - - context "with nil patch number" do - let(:patchlevel) { nil } - - it_behaves_like "the patchlevel is omitted" - end - - context "with negative patch number" do - let(:patchlevel) { -1 } - - it_behaves_like "the patchlevel is omitted" - end - - context "with a valid patch number" do - it "uses the specified patchlevel as patchlevel" do - expect(subject.to_gem_version_with_patchlevel.to_s).to eq("#{version}.#{patchlevel}") - end - end - end end end |