How to use fetch_quick_index method of Gem Package

Best Rr_ruby code snippet using Gem.fetch_quick_index

test_gem_source_index.rb

Source:test_gem_source_index.rb Github

copy

Full Screen

...7require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')8require 'rubygems/source_index'9require 'rubygems/config_file'10class Gem::SourceIndex11 public :fetcher, :fetch_bulk_index, :fetch_quick_index,12 :find_missing, :gems, :remove_extra,13 :update_with_missing, :unzip14end15class TestGemSourceIndex < RubyGemTestCase16 def setup17 super18 util_setup_fake_fetcher19 end20 def test_create_from_directory21 # TODO22 end23 def test_fetcher24 assert_equal @fetcher, @source_index.fetcher25 end26 def test_fetch_bulk_index_compressed27 util_setup_bulk_fetch true28 use_ui @ui do29 fetched_index = @source_index.fetch_bulk_index @uri30 assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,31 @c1_2.full_name].sort,32 fetched_index.gems.map { |n,s| n }.sort33 end34 paths = @fetcher.paths35 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift36 assert paths.empty?, paths.join(', ')37 end38 def test_fetch_bulk_index_error39 @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] = proc { raise SocketError }40 @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = proc { raise SocketError }41 @fetcher.data["#{@gem_repo}/yaml.Z"] = proc { raise SocketError }42 @fetcher.data["#{@gem_repo}/yaml"] = proc { raise SocketError }43 e = assert_raise Gem::RemoteSourceException do44 use_ui @ui do45 @source_index.fetch_bulk_index @uri46 end47 end48 paths = @fetcher.paths49 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift50 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift51 assert_equal "#{@gem_repo}/yaml.Z", paths.shift52 assert_equal "#{@gem_repo}/yaml", paths.shift53 assert paths.empty?, paths.join(', ')54 assert_equal 'Error fetching remote gem cache: SocketError',55 e.message56 end57 def test_fetch_bulk_index_fallback58 @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] =59 proc { raise SocketError }60 @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =61 proc { raise SocketError }62 @fetcher.data["#{@gem_repo}/yaml.Z"] = proc { raise SocketError }63 @fetcher.data["#{@gem_repo}/yaml"] = @source_index.to_yaml64 use_ui @ui do65 fetched_index = @source_index.fetch_bulk_index @uri66 assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,67 @c1_2.full_name].sort,68 fetched_index.gems.map { |n,s| n }.sort69 end70 paths = @fetcher.paths71 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift72 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift73 assert_equal "#{@gem_repo}/yaml.Z", paths.shift74 assert_equal "#{@gem_repo}/yaml", paths.shift75 assert paths.empty?, paths.join(', ')76 end77 def test_fetch_bulk_index_marshal_mismatch78 marshal = @source_index.dump79 marshal[0] = (Marshal::MAJOR_VERSION - 1).chr80 @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = marshal81 @fetcher.data["#{@gem_repo}/yaml"] = @source_index.to_yaml82 use_ui @ui do83 fetched_index = @source_index.fetch_bulk_index @uri84 assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,85 @c1_2.full_name].sort,86 fetched_index.gems.map { |n,s| n }.sort87 end88 paths = @fetcher.paths89 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift90 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift91 assert_equal "#{@gem_repo}/yaml.Z", paths.shift92 assert_equal "#{@gem_repo}/yaml", paths.shift93 assert paths.empty?, paths.join(', ')94 end95 def test_fetch_bulk_index_uncompressed96 util_setup_bulk_fetch false97 use_ui @ui do98 fetched_index = @source_index.fetch_bulk_index @uri99 assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,100 @c1_2.full_name].sort,101 fetched_index.gems.map { |n,s| n }.sort102 end103 paths = @fetcher.paths104 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift105 assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift106 assert paths.empty?, paths.join(', ')107 end108 def test_fetch_quick_index109 index = util_zip @gem_names110 latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")111 @fetcher.data["#{@gem_repo}/quick/index.rz"] = index112 @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = latest_index113 quick_index = @source_index.fetch_quick_index @uri, false114 assert_equal [@a2.full_name, @b2.full_name].sort,115 quick_index.sort116 paths = @fetcher.paths117 assert_equal "#{@gem_repo}/quick/latest_index.rz", paths.shift118 assert paths.empty?, paths.join(', ')119 end120 def test_fetch_quick_index_all121 index = util_zip @gem_names122 latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")123 @fetcher.data["#{@gem_repo}/quick/index.rz"] = index124 @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = latest_index125 quick_index = @source_index.fetch_quick_index @uri, true126 assert_equal [@a1.full_name, @a2.full_name, @b2.full_name].sort,127 quick_index.sort128 paths = @fetcher.paths129 assert_equal "#{@gem_repo}/quick/index.rz", paths.shift130 assert paths.empty?, paths.join(', ')131 end132 def test_fetch_quick_index_error133 @fetcher.data["#{@gem_repo}/quick/index.rz"] =134 proc { raise Exception }135 e = assert_raise Gem::OperationNotSupportedError do136 @source_index.fetch_quick_index @uri, true137 end138 assert_equal 'No quick index found: Exception', e.message139 paths = @fetcher.paths140 assert_equal "#{@gem_repo}/quick/index.rz", paths.shift141 assert paths.empty?, paths.join(', ')142 end143 def test_fetch_quick_index_fallback144 index = util_zip @gem_names145 @fetcher.data["#{@gem_repo}/quick/index.rz"] = index146 quick_index = @source_index.fetch_quick_index @uri, false147 assert_equal @gem_names.split, quick_index.sort148 paths = @fetcher.paths149 assert_equal "#{@gem_repo}/quick/latest_index.rz", paths.shift150 assert_equal "#{@gem_repo}/quick/index.rz", paths.shift151 assert paths.empty?, paths.join(', ')152 end153 def test_fetch_quick_index_subdir154 latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")155 repo = URI.parse "#{@gem_repo}/~nobody/mirror/"156 @fetcher.data["#{repo}quick/latest_index.rz"] = latest_index157 quick_index = @source_index.fetch_quick_index repo, false158 assert_equal [@a2.full_name, @b2.full_name].sort,159 quick_index.sort160 paths = @fetcher.paths161 assert_equal "#{repo}quick/latest_index.rz", paths.shift162 assert paths.empty?, paths.join(', ')163 end164 def test_fetch_single_spec165 a1_spec_url = "#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{@a1.full_name}.gemspec.rz"166 @fetcher.data[a1_spec_url] = util_zip Marshal.dump(@a1)167 spec = @source_index.send :fetch_single_spec, URI.parse(@gem_repo),168 @a1.full_name169 assert_equal @a1.full_name, spec.full_name170 paths = @fetcher.paths171 assert_equal a1_spec_url, paths.shift...

Full Screen

Full Screen

test_source_index.rb

Source:test_source_index.rb Github

copy

Full Screen

...7require 'test/gemutilities'8require 'rubygems/source_index'9Gem.manage_gems10class Gem::SourceIndex11 public :convert_specs, :fetcher, :fetch_bulk_index, :fetch_quick_index,12 :find_missing, :gems, :reduce_specs, :remove_extra,13 :update_with_missing, :unzip14end15class TestSourceIndex < RubyGemTestCase16 def setup17 super18 util_setup_fake_fetcher19 end20 def test_convert_specs21 specs = @source_index.convert_specs([@gem1].to_yaml)22 @gem1.files = []23 assert_equal [@gem1], specs24 end25 def test_create_from_directory26 # TODO27 end28 def test_fetcher29 assert_equal @fetcher, @source_index.fetcher30 end31 def test_fetch_bulk_index_compressed32 util_setup_bulk_fetch true33 use_ui MockGemUi.new do34 fetched_index = @source_index.fetch_bulk_index @uri35 assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,36 fetched_index.gems.map { |n,s| n }.sort37 end38 end39 def test_fetch_bulk_index_error40 @fetcher.data["http://gems.example.com/yaml.Z"] = proc { raise SocketError }41 @fetcher.data["http://gems.example.com/yaml"] = proc { raise SocketError }42 e = assert_raise Gem::RemoteSourceException do43 use_ui MockGemUi.new do44 @source_index.fetch_bulk_index @uri45 end46 end47 assert_equal 'Error fetching remote gem cache: SocketError',48 e.message49 end50 def test_fetch_bulk_index_uncompressed51 util_setup_bulk_fetch false52 use_ui MockGemUi.new do53 fetched_index = @source_index.fetch_bulk_index @uri54 assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,55 fetched_index.gems.map { |n,s| n }.sort56 end57 end58 def test_fetch_quick_index59 quick_index = util_zip @gem_names60 @fetcher.data['http://gems.example.com/quick/index.rz'] = quick_index61 quick_index = @source_index.fetch_quick_index @uri62 assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,63 quick_index.sort64 end65 def test_fetch_quick_index_error66 @fetcher.data['http://gems.example.com/quick/index.rz'] =67 proc { raise Exception }68 e = assert_raise Gem::OperationNotSupportedError do69 @source_index.fetch_quick_index @uri70 end71 assert_equal 'No quick index found: Exception', e.message72 end73 def test_find_missing74 missing = @source_index.find_missing [@gem3.full_name]75 assert_equal [@gem3.full_name], missing76 end77 def test_find_missing_none_missing78 missing = @source_index.find_missing @gem_names.split79 assert_equal [], missing80 end81 def test_latest_specs82 spec = quick_gem @gem1.name, '0.0.1'83 @source_index.add_spec spec...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful