How to use prerelease_specs method of Gem Package

Best Rr_ruby code snippet using Gem.prerelease_specs

test_gem_spec_fetcher.rb

Source:test_gem_spec_fetcher.rb Github

copy

Full Screen

...14 Gem::Specification.remove_spec @b215 all = Gem::Specification.map { |spec|16 Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)17 }.sort18 @prerelease_specs, @specs = all.partition { |g| g.prerelease? }19 # TODO: couldn't all of this come from the fake spec fetcher?20 @latest_specs = Gem::Specification.latest_specs.sort.map { |spec|21 Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)22 }23 v = Gem.marshal_version24 s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs)))25 l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs)))26 p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs)))27 @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip28 @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip29 @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip30 @sf = Gem::SpecFetcher.new31 @released = Gem::NameTuple.from_list \32 [["a", Gem::Version.new("1"), "ruby"],33 ["a", Gem::Version.new("2"), "ruby"],34 ["a_evil", Gem::Version.new("9"), "ruby"],35 ["c", Gem::Version.new("1.2"), "ruby"],36 ['dep_x', Gem::Version.new(1), 'ruby'],37 ["pl", Gem::Version.new("1"), "i386-linux"],38 ['x', Gem::Version.new(1), 'ruby']]39 end40 def test_initialize_unwritable_home_dir41 skip 'chmod not supported' if Gem.win_platform?42 FileUtils.chmod 0000, Gem.user_home43 begin44 assert Gem::SpecFetcher.new45 ensure46 FileUtils.chmod 0755, Gem.user_home47 end48 end49 def test_spec_for_dependency_all50 d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"51 @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))52 @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))53 @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))54 @fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))55 dep = Gem::Dependency.new 'a', ">= 1"56 specs_and_sources, _ = @sf.spec_for_dependency dep57 spec_names = specs_and_sources.map do |spec, source_uri|58 [spec.full_name, source_uri]59 end60 expected = [[@a1.full_name, @source], [@a2.full_name, @source]]61 assert_equal expected, spec_names62 assert_same specs_and_sources.first.last, specs_and_sources.last.last63 end64 def test_spec_for_dependency_latest65 d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"66 @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))67 @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))68 @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))69 dep = Gem::Dependency.new 'a'70 specs_and_sources, _ = @sf.spec_for_dependency dep71 spec_names = specs_and_sources.map do |spec, source_uri|72 [spec.full_name, source_uri]73 end74 assert_equal [[@a2.full_name, Gem::Source.new(@gem_repo)]], spec_names75 end76 def test_spec_for_dependency_prerelease77 d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"78 @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))79 @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))80 @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))81 specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a')82 spec_names = specs_and_sources.map do |spec, source_uri|83 [spec.full_name, source_uri]84 end85 assert_equal [[@a_pre.full_name, Gem::Source.new(@gem_repo)]], spec_names86 end87 def test_spec_for_dependency_platform88 util_set_arch 'i386-linux'89 @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =90 util_zip(Marshal.dump(@pl1))91 dep = Gem::Dependency.new 'pl', 192 specs_and_sources, _ = @sf.spec_for_dependency dep93 spec_names = specs_and_sources.map do |spec, source_uri|94 [spec.full_name, source_uri]95 end96 assert_equal [[@pl1.full_name, Gem::Source.new(@gem_repo)]], spec_names97 end98 def test_spec_for_dependency_mismatched_platform99 util_set_arch 'hrpa-989'100 @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =101 util_zip(Marshal.dump(@pl1))102 dep = Gem::Dependency.new 'pl', 1103 specs_and_sources, errors = @sf.spec_for_dependency dep104 assert_equal 0, specs_and_sources.size105 assert_equal 1, errors.size106 pmm = errors.first107 assert_equal "i386-linux", pmm.platforms.first108 assert_equal "Found pl (1), but was for platform i386-linux", pmm.wordy109 end110 def test_spec_for_dependency_bad_fetch_spec111 src = Gem::Source.new(@gem_repo)112 def src.fetch_spec(name)113 raise Gem::RemoteFetcher::FetchError.new("bad news from the internet", @uri)114 end115 Gem.sources.replace [src]116 d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"117 @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))118 @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2))119 @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre))120 @fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a))121 dep = Gem::Dependency.new 'a', ">= 1"122 specs_and_sources, errors = @sf.spec_for_dependency dep123 assert_equal [], specs_and_sources124 sfp = errors.first125 assert_kind_of Gem::SourceFetchProblem, sfp126 assert_equal src, sfp.source127 assert_equal "bad news from the internet (#{@gem_repo})", sfp.error.message128 end129 def test_available_specs_latest130 specs, _ = @sf.available_specs(:latest)131 assert_equal [@source], specs.keys132 assert_equal @latest_specs, specs[@source].sort133 end134 def test_available_specs_released135 specs, _ = @sf.available_specs(:released)136 assert_equal [@source], specs.keys137 assert_equal @released, specs[@source].sort138 end139 def test_available_specs_complete140 specs, _ = @sf.available_specs(:complete)141 assert_equal [@source], specs.keys142 comp = @prerelease_specs + @released143 assert_equal comp.sort, specs[@source].sort144 end145 def test_available_specs_complete_handles_no_prerelease146 v = Gem.marshal_version147 @fetcher.data.delete "#{@gem_repo}prerelease_specs.#{v}.gz"148 specs, _ = @sf.available_specs(:complete)149 assert_equal [@source], specs.keys150 comp = @released151 assert_equal comp.sort, specs[@source].sort152 end153 def test_available_specs_cache154 specs, _ = @sf.available_specs(:latest)155 refute specs[@source].empty?156 @fetcher.data["#{@gem_repo}/latest_specs.#{Gem.marshal_version}.gz"] = nil157 cached_specs, _ = @sf.available_specs(:latest)158 assert_equal specs, cached_specs159 end160 def test_available_specs_cache_released161 specs, _ = @sf.available_specs(:released)162 refute specs[@source].empty?163 @fetcher.data["#{@gem_repo}/specs.#{Gem.marshal_version}.gz"] = nil164 cached_specs, _ = @sf.available_specs(:released)165 assert_equal specs, cached_specs166 end167 def test_available_specs_prerelease168 specs, _ = @sf.available_specs(:prerelease)169 assert_equal @prerelease_specs, specs[@source].sort170 end171 def test_available_specs_with_bad_source172 Gem.sources.replace ["http://not-there.nothing"]173 specs, errors = @sf.available_specs(:latest)174 assert_equal({}, specs)175 assert_kind_of Gem::SourceFetchProblem, errors.first176 end177end...

Full Screen

Full Screen

rubygems_integration_spec.rb

Source:rubygems_integration_spec.rb Github

copy

Full Screen

...59 describe "#fetch_all_remote_specs" do60 let(:uri) { "https://example.com" }61 let(:fetcher) { double("gem_remote_fetcher") }62 let(:specs_response) { Marshal.dump(["specs"]) }63 let(:prerelease_specs_response) { Marshal.dump(["prerelease_specs"]) }64 context "when a rubygems source mirror is set" do65 let(:orig_uri) { Bundler::URI("http://zombo.com") }66 let(:remote_with_mirror) { double("remote", :uri => uri, :original_uri => orig_uri) }67 it "sets the 'X-Gemfile-Source' header containing the original source" do68 expect(Bundler.rubygems).to receive(:gem_remote_fetcher).twice.and_return(fetcher)69 expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "http://zombo.com").twice70 expect(fetcher).to receive(:fetch_path).with(uri + "specs.4.8.gz").and_return(specs_response)71 expect(fetcher).to receive(:fetch_path).with(uri + "prerelease_specs.4.8.gz").and_return(prerelease_specs_response)72 result = Bundler.rubygems.fetch_all_remote_specs(remote_with_mirror)73 expect(result).to eq(%w[specs prerelease_specs])74 end75 end76 context "when there is no rubygems source mirror set" do77 let(:remote_no_mirror) { double("remote", :uri => uri, :original_uri => nil) }78 it "does not set the 'X-Gemfile-Source' header" do79 expect(Bundler.rubygems).to receive(:gem_remote_fetcher).twice.and_return(fetcher)80 expect(fetcher).to_not receive(:headers=)81 expect(fetcher).to receive(:fetch_path).with(uri + "specs.4.8.gz").and_return(specs_response)82 expect(fetcher).to receive(:fetch_path).with(uri + "prerelease_specs.4.8.gz").and_return(prerelease_specs_response)83 result = Bundler.rubygems.fetch_all_remote_specs(remote_no_mirror)84 expect(result).to eq(%w[specs prerelease_specs])85 end86 end87 end88end...

Full Screen

Full Screen

index_spec.rb

Source:index_spec.rb Github

copy

Full Screen

...4 gem = double("gem")5 specs = double("specs").as_null_object6 latest_specs = double("latest specs")7 expect(latest_specs).to receive(:add).with(gem)8 prerelease_specs = double("latest specs").as_null_object9 quick_marshal_specs = double("quick marshal specs").as_null_object10 subject.specs = specs11 subject.latest_specs = latest_specs12 subject.prerelease_specs = prerelease_specs13 subject.quick_marshal_specs = quick_marshal_specs14 subject.add(gem)15 end16 it "adds a gem to specs" do17 gem = double("gem")18 specs = double("specs")19 expect(specs).to receive(:add).with(gem)20 latest_specs = double("latest specs").as_null_object21 prerelease_specs = double("latest specs").as_null_object22 quick_marshal_specs = double("quick marshal specs").as_null_object23 subject.specs = specs24 subject.prerelease_specs = prerelease_specs25 subject.latest_specs = latest_specs26 subject.quick_marshal_specs = quick_marshal_specs27 subject.add(gem)28 end29 it "adds a gem to the prerelease specs" do30 gem = double("gem")31 specs = double("specs").as_null_object32 latest_specs = double("latest specs").as_null_object33 prerelease_specs = double("prerelease specs")34 expect(prerelease_specs).to receive(:add).with(gem)35 quick_marshal_specs = double("quick marshal specs").as_null_object36 subject.specs = specs37 subject.latest_specs = latest_specs38 subject.prerelease_specs = prerelease_specs39 subject.quick_marshal_specs = quick_marshal_specs40 subject.add(gem)41 end42 it "adds a gem to the quick marshal specs" do43 gem = double("gem")44 specs = double("specs").as_null_object45 latest_specs = double("latest specs").as_null_object46 prerelease_specs = double("latest specs").as_null_object47 quick_marshal_specs = double("quick marshal specs")48 expect(quick_marshal_specs).to receive(:add).with(gem)49 subject.specs = specs50 subject.latest_specs = latest_specs51 subject.prerelease_specs = prerelease_specs52 subject.quick_marshal_specs = quick_marshal_specs53 subject.add(gem)54 end55end...

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1puts Gem.prerelease_specs.map(&:name).sort2puts Gem::Specification.prerelease_specs.map(&:name).sort3puts Gem::Specification.latest_specs.select(&:prerelease?).map(&:name).sort4puts Gem::Specification.latest_specs.reject(&:prerelease?).map(&:name).sort5puts Gem::Specification.latest_specs.map(&:name).sort6puts Gem::Specification.latest_specs.map(&:name).sort7puts Gem::Specification.prerelease_specs.map(&:name).sort8puts Gem::Specification.latest_specs.map(&:name).sort9puts Gem::Specification.prerelease_specs.map(&:name).sort10puts Gem::Specification.latest_specs.map(&:name).sort11puts Gem::Specification.prerelease_specs.map(&:name).sort12puts Gem::Specification.latest_specs.map(&:name).sort13puts Gem::Specification.prerelease_specs.map(&:name).sort14puts Gem::Specification.latest_specs.map(&:name).sort15puts Gem::Specification.prerelease_specs.map(&:name).sort16puts Gem::Specification.latest_specs.map(&:name).sort17puts Gem::Specification.prerelease_specs.map(&:name).sort

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1Gem::Commands::InstallCommand.new.invoke(*ARGV)2Gem::Commands::InstallCommand.new.invoke(*ARGV)3Gem::Commands::InstallCommand.new.invoke(*ARGV)4Gem::Commands::InstallCommand.new.invoke(*ARGV)5Gem::Commands::InstallCommand.new.invoke(*ARGV)6Gem::Commands::InstallCommand.new.invoke(*ARGV)7Gem::Commands::InstallCommand.new.invoke(*ARGV)8Gem::Commands::InstallCommand.new.invoke(*ARGV)

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1gem = Gem::Specification.find_by_name('mygem')2version = Gem::Version.new(version) unless version.is_a? Gem::Version3prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }4gem = Gem::Specification.find_by_name('mygem')5version = Gem::Version.new(version) unless version.is_a? Gem::Version6prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }7gem = Gem::Specification.find_by_name('mygem')8version = Gem::Version.new(version) unless version.is_a? Gem::Version9prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1spec = specs.find{|s| s.name == gem_name && s.version.to_s == version}2 spec = fetcher.fetch_spec(spec)3printer = RubyProf::FlatPrinter.new(result)4printer.print(STDOUT)

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1gem = Gem::Specification.find_by_name('mygem')2version = Gem::Version.new(version) unless version.is_a? Gem::Version3prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }4gem = Gem::Specification.find_by_name('mygem')5version = Gem::Version.new(version) unless version.is_a? Gem::Version6prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }7gem = Gem::Specification.find_by_name('mygem')8version = Gem::Version.new(version) unless version.is_a? Gem::Version9prerelease = Gem.prerelease_specs('mygem').find { |spec| spec.version > version }

Full Screen

Full Screen

prerelease_specs

Using AI Code Generation

copy

Full Screen

1spec = specs.find{|s| s.name == gem_name && s.version.to_s == version}2 spec = fetcher.fetch_spec(spec)3printer = RubyProf::FlatPrinter.new(result)4printer.print(STDOUT)

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