diff options
author | Asutosh Palai <asupalai@gmail.com> | 2016-06-09 20:20:18 +0530 |
---|---|---|
committer | Asutosh Palai <asupalai@gmail.com> | 2016-06-09 20:24:29 +0530 |
commit | f684a6d9d184b9acb9a12fb1009d4c1a18db71ac (patch) | |
tree | e390cec062ec1fdcadfa475183568db2f2c2b88c | |
parent | df5a8e97044a92965e25a344da89f550ab570956 (diff) | |
download | bundler-f684a6d9d184b9acb9a12fb1009d4c1a18db71ac.tar.gz |
Fixed the errors in spec for older versions
-rw-r--r-- | lib/bundler/plugin/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/yaml_serializer.rb | 10 | ||||
-rw-r--r-- | spec/bundler/plugin/installer_spec.rb | 3 | ||||
-rw-r--r-- | spec/bundler/yaml_serializer_spec.rb | 48 |
4 files changed, 40 insertions, 23 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 64d7f8a372..2c10bb24c8 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -17,7 +17,7 @@ module Bundler if options[:git] install_git(names, version, options) else - sources = options[:source] || Gem.sources.sources.map(&:uri) + sources = options[:source] || Bundler.rubygems.sources install_rubygems(names, version, sources) end end diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb index 327baa4ee7..015fd17c6f 100644 --- a/lib/bundler/yaml_serializer.rb +++ b/lib/bundler/yaml_serializer.rb @@ -40,7 +40,6 @@ module Bundler res = {} stack = [res] str.scan(SCAN_REGEX).each do |(indent, key, _, val)| - key = convert_to_backward_compatible_key(key) depth = indent.scan(/ /).length if val.empty? new_hash = {} @@ -53,15 +52,8 @@ module Bundler res end - # for settings' keys - def convert_to_backward_compatible_key(key) - key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z} - key = key.gsub(".", "__") if key.include?(".") - key - end - class << self - private :dump_hash, :convert_to_backward_compatible_key + private :dump_hash end end end diff --git a/spec/bundler/plugin/installer_spec.rb b/spec/bundler/plugin/installer_spec.rb index f74d025403..33a0ddea48 100644 --- a/spec/bundler/plugin/installer_spec.rb +++ b/spec/bundler/plugin/installer_spec.rb @@ -6,7 +6,8 @@ describe Bundler::Plugin::Installer do describe "cli install" do it "uses Gem.sources when non of the source is provided" do - sources = Gem.sources.sources.map(&:uri) + sources = double(:sources) + allow(Bundler).to receive_message_chain("rubygems.sources") { sources } allow(installer).to receive(:install_rubygems). with("new-plugin", [">= 0"], sources).once diff --git a/spec/bundler/yaml_serializer_spec.rb b/spec/bundler/yaml_serializer_spec.rb index 59906deb81..53dbbc6766 100644 --- a/spec/bundler/yaml_serializer_spec.rb +++ b/spec/bundler/yaml_serializer_spec.rb @@ -7,13 +7,11 @@ describe Bundler::YAMLSerializer do describe "#dump" do it "works for simple hash" do - hash = { "Q" => "Where does Thursday come before Wednesday?", - "Ans" => "In the dictionary. :P" } + hash = { "Q" => "Where does Thursday come before Wednesday? In the dictionary. :P" } expected = strip_whitespace <<-YAML --- - Q: "Where does Thursday come before Wednesday?" - Ans: "In the dictionary. :P" + Q: "Where does Thursday come before Wednesday? In the dictionary. :P" YAML expect(serializer.dump(hash)).to eq(expected) @@ -21,19 +19,15 @@ describe Bundler::YAMLSerializer do it "handles nested hash" do hash = { - "a_joke" => { - "my-stand" => "I can totally keep secrets", - "my-explanation" => "It's the people I tell them to that can't", + "nice-one" => { + "read_ahead" => "All generalizations are false, including this one", }, - "read_ahead" => "All generalizations are false, including this one", } expected = strip_whitespace <<-YAML --- - a_joke: - my-stand: "I can totally keep secrets" - my-explanation: "It's the people I tell them to that can't" - read_ahead: "All generalizations are false, including this one" + nice-one: + read_ahead: "All generalizations are false, including this one" YAML expect(serializer.dump(hash)).to eq(expected) @@ -85,4 +79,34 @@ describe Bundler::YAMLSerializer do expect(serializer.load(yaml)).to eq("BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://rubygems-mirror.org") end end + + describe "against yaml lib" do + let(:hash) do + { + "a_joke" => { + "my-stand" => "I can totally keep secrets", + "but" => "The people I tell them to can't :P", + }, + "sales" => { + "item" => "A Parachute", + "description" => "Only used once, never opened.", + }, + "one-more" => "I'd tell you a chemistry joke but I know I wouldn't get a reaction.", + } + end + + context "#load" do + it "retrieves the original hash" do + require "yaml" + expect(serializer.load(YAML.dump(hash))).to eq(hash) + end + end + + context "#dump" do + it "retrieves the original hash" do + require "yaml" + expect(YAML.load(serializer.dump(hash))).to eq(hash) + end + end + end end |