2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/commands/query_command'
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
module TestGemCommandsQueryCommandSetup
|
2007-11-10 02:48:56 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Commands::QueryCommand.new
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
@specs = add_gems_to_fetcher
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_ui = Gem::MockGemUi.new
|
|
|
|
@stub_fetcher = Gem::FakeFetcher.new
|
2018-08-27 06:05:06 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
|
2008-03-31 18:40:06 -04:00
|
|
|
raise Gem::RemoteFetcher::FetchError
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
include TestGemCommandsQueryCommandSetup
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
def test_execute
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.handle_options %w[-r]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
a (2)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2010-04-22 04:24:42 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_all
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.handle_options %w[-r --all]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (2, 1)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
2008-03-31 18:40:06 -04:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_execute_all_prerelease
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
@cmd.handle_options %w[-r --all --prerelease]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2010-02-21 21:52:35 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (3.a, 2, 1)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
2010-02-21 21:52:35 -05:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2010-02-21 21:52:35 -05:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_details
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.summary = 'This is a lot of text. ' * 4
|
|
|
|
s.authors = ['Abraham Lincoln', 'Hirohito']
|
|
|
|
s.homepage = 'http://a.example.com/'
|
|
|
|
end
|
2008-06-17 18:04:18 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
2008-06-17 18:04:18 -04:00
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.handle_options %w[-r -d]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
2008-04-11 16:57:02 -04:00
|
|
|
a (2)
|
2008-06-17 18:04:18 -04:00
|
|
|
Authors: Abraham Lincoln, Hirohito
|
|
|
|
Homepage: http://a.example.com/
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
This is a lot of text. This is a lot of text. This is a lot of text.
|
|
|
|
This is a lot of text.
|
|
|
|
|
2017-08-28 04:31:28 -04:00
|
|
|
pl (1)
|
|
|
|
Platform: i386-linux
|
|
|
|
Author: A User
|
|
|
|
Homepage: http://example.com
|
|
|
|
|
|
|
|
this is a summary
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2017-08-28 04:31:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_details_cleans_text
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.summary = 'This is a lot of text. ' * 4
|
|
|
|
s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
|
|
|
|
s.homepage = "http://a.example.com/\x03"
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[-r -d]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2017-08-28 04:31:28 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (2)
|
|
|
|
Authors: Abraham Lincoln ., . Hirohito
|
|
|
|
Homepage: http://a.example.com/.
|
|
|
|
|
|
|
|
This is a lot of text. This is a lot of text. This is a lot of text.
|
|
|
|
This is a lot of text.
|
|
|
|
|
|
|
|
pl (1)
|
|
|
|
Platform: i386-linux
|
|
|
|
Author: A User
|
|
|
|
Homepage: http://example.com
|
|
|
|
|
|
|
|
this is a summary
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2017-08-28 04:31:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_details_truncates_summary
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.summary = 'This is a lot of text. ' * 10_000
|
|
|
|
s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
|
|
|
|
s.homepage = "http://a.example.com/\x03"
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[-r -d]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2017-08-28 04:31:28 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (2)
|
|
|
|
Authors: Abraham Lincoln ., . Hirohito
|
|
|
|
Homepage: http://a.example.com/.
|
|
|
|
|
|
|
|
Truncating the summary for a-2 to 100,000 characters:
|
|
|
|
#{" This is a lot of text. This is a lot of text. This is a lot of text.\n" * 1449} This is a lot of te
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
pl (1)
|
|
|
|
Platform: i386-linux
|
2008-06-17 18:04:18 -04:00
|
|
|
Author: A User
|
|
|
|
Homepage: http://example.com
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
this is a summary
|
2007-11-10 02:48:56 -05:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_installed
|
2011-05-31 23:45:05 -04:00
|
|
|
@cmd.handle_options %w[-n a --installed]
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
assert_raises Gem::MockGemUi::SystemExitException do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "true\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2013-07-22 18:46:50 -04:00
|
|
|
def test_execute_installed_inverse
|
|
|
|
@cmd.handle_options %w[-n a --no-installed]
|
|
|
|
|
|
|
|
e = assert_raises Gem::MockGemUi::TermError do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-07-22 18:46:50 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "false\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-07-22 18:46:50 -04:00
|
|
|
|
|
|
|
assert_equal 1, e.exit_code
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_installed_inverse_not_installed
|
|
|
|
@cmd.handle_options %w[-n not_installed --no-installed]
|
|
|
|
|
|
|
|
assert_raises Gem::MockGemUi::SystemExitException do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-07-22 18:46:50 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "true\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-07-22 18:46:50 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_installed_no_name
|
|
|
|
@cmd.handle_options %w[--installed]
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
e = assert_raises Gem::MockGemUi::TermError do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal '', @stub_ui.output
|
|
|
|
assert_equal "ERROR: You must specify a gem name\n", @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
assert_equal 4, e.exit_code
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_installed_not_installed
|
|
|
|
@cmd.handle_options %w[-n not_installed --installed]
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
e = assert_raises Gem::MockGemUi::TermError do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "false\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
assert_equal 1, e.exit_code
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_installed_version
|
2011-05-31 23:45:05 -04:00
|
|
|
@cmd.handle_options %w[-n a --installed --version 2]
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
assert_raises Gem::MockGemUi::SystemExitException do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "true\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_installed_version_not_installed
|
|
|
|
@cmd.handle_options %w[-n c --installed --version 2]
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
e = assert_raises Gem::MockGemUi::TermError do
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "false\n", @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
assert_equal 1, e.exit_code
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
def test_execute_local
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.options[:domain] = :local
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (3.a, 2, 1)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-09-18 17:29:41 -04:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
def test_execute_local_notty
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
@cmd.handle_options %w[]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_ui.outs.tty = false
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-09-25 06:13:50 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
2009-06-09 17:38:59 -04:00
|
|
|
a (3.a, 2, 1)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
2008-09-25 06:13:50 -04:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-09-25 06:13:50 -04:00
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
def test_execute_local_quiet
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.options[:domain] = :local
|
|
|
|
Gem.configuration.verbose = false
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
a (3.a, 2, 1)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-09-18 17:29:41 -04:00
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_no_versions
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.handle_options %w[-r --no-versions]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
a
|
|
|
|
pl
|
2007-11-10 02:48:56 -05:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
def test_execute_notty
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2008-09-25 06:13:50 -04:00
|
|
|
@cmd.handle_options %w[-r]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_ui.outs.tty = false
|
2008-09-25 06:13:50 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2008-09-25 06:13:50 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
a (2)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
2008-09-25 06:13:50 -04:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2008-09-25 06:13:50 -04:00
|
|
|
end
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
def test_execute_prerelease
|
|
|
|
@cmd.handle_options %w[-r --prerelease]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2009-06-09 17:38:59 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (3.a)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2009-06-09 17:38:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_prerelease_local
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
@cmd.handle_options %w[-l --prerelease]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2009-06-09 17:38:59 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (3.a, 2, 1)
|
2010-04-22 04:24:42 -04:00
|
|
|
pl (1 i386-linux)
|
2009-06-09 17:38:59 -04:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2019-06-01 05:45:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_no_prerelease_local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[-l --no-prerelease]
|
|
|
|
|
|
|
|
use_ui @stub_ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (2, 1)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
|
|
|
assert_equal expected, @stub_ui.output
|
2009-06-09 17:38:59 -04:00
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
def test_execute_remote
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.options[:domain] = :remote
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
a (2)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-09-18 17:29:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_remote_notty
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.handle_options %w[]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_ui.outs.tty = false
|
2013-09-18 17:29:41 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
a (3.a, 2, 1)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-09-18 17:29:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_remote_quiet
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.options[:domain] = :remote
|
|
|
|
Gem.configuration.verbose = false
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
a (2)
|
|
|
|
pl (1 i386-linux)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2013-09-18 17:29:41 -04:00
|
|
|
end
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
def test_make_entry
|
|
|
|
a_2_name = @specs['a-2'].original_name
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
@stub_fetcher.data.delete \
|
2015-07-01 17:50:14 -04:00
|
|
|
"#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz"
|
|
|
|
|
|
|
|
a2 = @specs['a-2']
|
|
|
|
entry_tuples = [
|
|
|
|
[Gem::NameTuple.new(a2.name, a2.version, a2.platform),
|
|
|
|
Gem.sources.first],
|
|
|
|
]
|
|
|
|
|
|
|
|
platforms = { a2.version => [a2.platform] }
|
|
|
|
|
|
|
|
entry = @cmd.send :make_entry, entry_tuples, platforms
|
|
|
|
|
|
|
|
assert_equal 'a (2)', entry
|
|
|
|
end
|
|
|
|
|
|
|
|
# Test for multiple args handling!
|
|
|
|
def test_execute_multiple_args
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[a pl]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2015-07-01 17:50:14 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_match %r%^a %, @stub_ui.output
|
|
|
|
assert_match %r%^pl %, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_show_gems
|
|
|
|
@cmd.options[:name] = //
|
|
|
|
@cmd.options[:domain] = :remote
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2019-06-01 05:45:11 -04:00
|
|
|
@cmd.send :show_gems, /a/i
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_match %r%^a %, @stub_ui.output
|
|
|
|
refute_match %r%^pl %, @stub_ui.output
|
|
|
|
assert_empty @stub_ui.error
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def add_gems_to_fetcher
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
fetcher.spec 'a', '3.a'
|
|
|
|
end
|
|
|
|
end
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
include TestGemCommandsQueryCommandSetup
|
|
|
|
|
|
|
|
def test_execute_platform
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 1 do |s|
|
|
|
|
s.platform = 'x86-linux'
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.platform = 'universal-darwin'
|
|
|
|
end
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
@cmd.handle_options %w[-r -a]
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2012-11-29 01:52:18 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
2013-11-11 19:16:41 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
*** REMOTE GEMS ***
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
a (2 universal-darwin, 1 ruby x86-linux)
|
2012-11-29 01:52:18 -05:00
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
|
|
|
assert_equal '', @stub_ui.error
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2016-04-06 02:01:14 -04:00
|
|
|
def test_execute_show_default_gems
|
|
|
|
spec_fetcher { |fetcher| fetcher.spec 'a', 2 }
|
|
|
|
|
|
|
|
a1 = new_default_spec 'a', 1
|
|
|
|
install_default_specs a1
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2016-04-06 02:01:14 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (2, default: 1)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2016-04-06 02:01:14 -04:00
|
|
|
end
|
|
|
|
|
2017-10-07 21:32:18 -04:00
|
|
|
def test_execute_show_default_gems_with_platform
|
|
|
|
a1 = new_default_spec 'a', 1
|
|
|
|
a1.platform = 'java'
|
|
|
|
install_default_specs a1
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2017-10-07 21:32:18 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (default: 1 java)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2017-10-07 21:32:18 -04:00
|
|
|
end
|
|
|
|
|
2012-12-19 02:19:10 -05:00
|
|
|
def test_execute_default_details
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
a1 = new_default_spec 'a', 1
|
|
|
|
install_default_specs a1
|
2012-12-19 02:19:10 -05:00
|
|
|
|
|
|
|
@cmd.handle_options %w[-l -d]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2012-12-19 02:19:10 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
a (2, 1)
|
2012-12-19 02:19:10 -05:00
|
|
|
Author: A User
|
|
|
|
Homepage: http://example.com
|
2013-11-11 19:16:41 -05:00
|
|
|
Installed at (2): #{@gemhome}
|
|
|
|
(1, default): #{a1.base_dir}
|
2012-12-19 02:19:10 -05:00
|
|
|
|
|
|
|
this is a summary
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2012-12-19 02:19:10 -05:00
|
|
|
end
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
def test_execute_local_details
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1 do |s|
|
|
|
|
s.platform = 'x86-linux'
|
|
|
|
end
|
2013-03-05 17:40:53 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.summary = 'This is a lot of text. ' * 4
|
|
|
|
s.authors = ['Abraham Lincoln', 'Hirohito']
|
|
|
|
s.homepage = 'http://a.example.com/'
|
|
|
|
s.platform = 'universal-darwin'
|
|
|
|
end
|
2013-03-05 17:40:53 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.legacy_platform
|
|
|
|
end
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
@cmd.handle_options %w[-l -d]
|
2013-09-18 17:29:41 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2013-09-18 17:29:41 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
str = @stub_ui.output
|
2013-09-18 17:29:41 -04:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
str.gsub!(/\(\d\): [^\n]*/, "-")
|
|
|
|
str.gsub!(/at: [^\n]*/, "at: -")
|
2013-10-15 20:14:16 -04:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
expected = <<-EOF
|
2013-10-15 20:14:16 -04:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
a (2, 1)
|
|
|
|
Platforms:
|
|
|
|
1: x86-linux
|
|
|
|
2: universal-darwin
|
|
|
|
Authors: Abraham Lincoln, Hirohito
|
|
|
|
Homepage: http://a.example.com/
|
|
|
|
Installed at -
|
|
|
|
-
|
|
|
|
|
|
|
|
This is a lot of text. This is a lot of text. This is a lot of text.
|
|
|
|
This is a lot of text.
|
|
|
|
|
|
|
|
pl (1)
|
|
|
|
Platform: i386-linux
|
|
|
|
Author: A User
|
|
|
|
Homepage: http://example.com
|
|
|
|
Installed at: -
|
|
|
|
|
|
|
|
this is a summary
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
|
2017-05-01 07:40:46 -04:00
|
|
|
def test_execute_exact_remote
|
2016-02-01 07:43:26 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'coolgem-omg', 3
|
|
|
|
fetcher.spec 'coolgem', '4.2.1'
|
|
|
|
fetcher.spec 'wow_coolgem', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[--remote --exact coolgem]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2016-02-01 07:43:26 -05:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** REMOTE GEMS ***
|
|
|
|
|
|
|
|
coolgem (4.2.1)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2016-02-01 07:43:26 -05:00
|
|
|
end
|
|
|
|
|
2017-05-01 07:40:46 -04:00
|
|
|
def test_execute_exact_local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'coolgem-omg', 3
|
|
|
|
fetcher.spec 'coolgem', '4.2.1'
|
|
|
|
fetcher.spec 'wow_coolgem', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[--exact coolgem]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2017-05-01 07:40:46 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
coolgem (4.2.1)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2017-05-01 07:40:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_exact_multiple
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'coolgem-omg', 3
|
|
|
|
fetcher.spec 'coolgem', '4.2.1'
|
|
|
|
fetcher.spec 'wow_coolgem', 1
|
|
|
|
|
|
|
|
fetcher.spec 'othergem-omg', 3
|
|
|
|
fetcher.spec 'othergem', '1.2.3'
|
|
|
|
fetcher.spec 'wow_othergem', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.handle_options %w[--exact coolgem othergem]
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
use_ui @stub_ui do
|
2017-05-01 07:40:46 -04:00
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = <<-EOF
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
coolgem (4.2.1)
|
|
|
|
|
|
|
|
*** LOCAL GEMS ***
|
|
|
|
|
|
|
|
othergem (1.2.3)
|
|
|
|
EOF
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal expected, @stub_ui.output
|
2017-05-01 07:40:46 -04:00
|
|
|
end
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
private
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
def add_gems_to_fetcher
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'a', 1
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
fetcher.download 'a', '3.a'
|
|
|
|
end
|
|
|
|
end
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
end
|