Project

General

Profile

Backport #8617 » rubygems.2_0_5.ruby.2_0_0.patch

drbrain (Eric Hodel), 07/12/2013 10:10 AM

View differences:

lib/rubygems/commands/help_command.rb (working copy)
113 113
      format = "#{' ' * margin_width}%-#{desc_width}s%s"
114 114

  
115 115
      command_manager.command_names.each do |cmd_name|
116
        summary = command_manager[cmd_name].summary
116
        command = command_manager[cmd_name]
117

  
118
        summary =
119
          if command then
120
            command.summary
121
          else
122
            "[No command found for #{cmd_name}, bug?]"
123
          end
124

  
117 125
        summary = wrap(summary, summary_width).split "\n"
118 126
        out << sprintf(format, cmd_name, summary.shift)
119 127
        until summary.empty? do
lib/rubygems/commands/list_command.rb (working copy)
7 7

  
8 8
class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
9 9

  
10
  def initialize(name = 'list',
11
                 summary = 'Display gems whose name starts with STRING')
12
    super name, summary
10
  def initialize
11
    super 'list', 'Display gems whose name starts with STRING'
13 12

  
14 13
    remove_option('--name-matches')
15 14
  end
......
27 26
  end
28 27

  
29 28
  def execute
30
    name = get_one_optional_argument || ''
31
    options[:name] = /^#{name}/i
32

  
29
    string = get_one_optional_argument || ''
30
    options[:name] = /^#{string}/i
33 31
    super
34 32
  end
35 33

  
lib/rubygems/commands/owner_command.rb (working copy)
73 73
          request.add_field "Authorization", api_key
74 74
        end
75 75

  
76
        with_response response
76
        with_response response, "Removing #{owner}"
77 77
      rescue
78 78
        # ignore
79 79
      end
lib/rubygems/commands/pristine_command.rb (working copy)
10 10
  def initialize
11 11
    super 'pristine',
12 12
          'Restores installed gems to pristine condition from files located in the gem cache',
13
          :version => Gem::Requirement.default, :extensions => true,
13
          :version => Gem::Requirement.default,
14
          :extensions => true,
14 15
          :all => false
15 16

  
16 17
    add_option('--all',
......
37 38
  end
38 39

  
39 40
  def defaults_str # :nodoc:
40
    "--all --extensions"
41
    '--extensions'
41 42
  end
42 43

  
43 44
  def description # :nodoc:
......
52 53
If the cached gem cannot be found, you will need to use `gem install` to
53 54
revert the gem.
54 55

  
55
If --no-extensions is provided pristine will not attempt to restore gems with
56
extensions.
56
If --no-extensions is provided pristine will not attempt to restore gems
57
with extensions.
57 58
    EOF
58 59
  end
59 60

  
lib/rubygems/commands/push_command.rb (working copy)
20 20
  end
21 21

  
22 22
  def initialize
23
    super 'push', description
23
    super 'push', description, :host => self.host
24

  
24 25
    add_proxy_option
25 26
    add_key_option
26 27

  
lib/rubygems/commands/search_command.rb (working copy)
1 1
require 'rubygems/command'
2
require 'rubygems/commands/list_command'
2
require 'rubygems/commands/query_command'
3 3

  
4
class Gem::Commands::SearchCommand < Gem::Commands::ListCommand
4
class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
5 5

  
6 6
  def initialize
7 7
    super 'search', 'Display all gems whose name contains STRING'
8 8

  
9
    @defaults[:domain] = :remote
9
    remove_option '--name-matches'
10
  end
11

  
12
  def arguments # :nodoc:
13
    "STRING        fragment of gem name to search for"
10 14
  end
11 15

  
12 16
  def defaults_str # :nodoc:
13 17
    "--remote --no-details"
14 18
  end
15 19

  
20
  def usage # :nodoc:
21
    "#{program_name} [STRING]"
22
  end
23

  
24
  def execute
25
    string = get_one_optional_argument
26
    options[:name] = /#{string}/i
27
    super
28
  end
29

  
16 30
end
17 31

  
lib/rubygems/commands/setup_command.rb (working copy)
159 159

  
160 160
    options[:previous_version] = Gem::Version.new(options[:previous_version])
161 161

  
162
    release_notes = File.join Dir.pwd, 'History.txt'
163

  
164
    release_notes = if File.exist? release_notes then
165
                      history = File.read release_notes
166
                      history = history.sub(/^# coding:.*?^=/m, '')
167

  
168
                      text = history.split(HISTORY_HEADER)
169
                      text.shift # correct an off-by-one generated by split
170
                      version_lines = history.scan(HISTORY_HEADER)
171
                      versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) }
172

  
173
                      history_string = ""
174

  
175
                      until versions.length == 0 or versions.shift < options[:previous_version]
176
                        history_string += version_lines.shift + text.shift
177
                      end
178

  
179
                      history_string
180
                    else
181
                      "Oh-no! Unable to find release notes!"
182
                    end
183

  
184
    say release_notes
162
    show_release_notes
185 163

  
186 164
    say
187 165
    say "-" * 78
......
458 436
    end
459 437
  end
460 438

  
439
  def show_release_notes
440
    release_notes = File.join Dir.pwd, 'History.txt'
441

  
442
    release_notes =
443
      if File.exist? release_notes then
444
        history = File.read release_notes
445

  
446
        history.force_encoding Encoding::UTF_8 if
447
          Object.const_defined? :Encoding
448

  
449
        history = history.sub(/^# coding:.*?^=/m, '')
450

  
451
        text = history.split(HISTORY_HEADER)
452
        text.shift # correct an off-by-one generated by split
453
        version_lines = history.scan(HISTORY_HEADER)
454
        versions = history.scan(VERSION_MATCHER).flatten.map do |x|
455
          Gem::Version.new(x)
456
        end
457

  
458
        history_string = ""
459

  
460
        until versions.length == 0 or
461
              versions.shift < options[:previous_version] do
462
          history_string += version_lines.shift + text.shift
463
        end
464

  
465
        history_string
466
      else
467
        "Oh-no! Unable to find release notes!"
468
      end
469

  
470
    say release_notes
471
  end
472

  
461 473
  def uninstall_old_gemcutter
462 474
    require 'rubygems/uninstaller'
463 475

  
lib/rubygems/commands/specification_command.rb (working copy)
28 28
      options[:format] = :ruby
29 29
    end
30 30

  
31
    add_option('--yaml', 'Output RUBY format') do |value, options|
31
    add_option('--yaml', 'Output YAML format') do |value, options|
32 32
      options[:format] = :yaml
33 33
    end
34 34

  
lib/rubygems/commands/update_command.rb (working copy)
94 94

  
95 95
    say "Updating #{name}"
96 96
    begin
97
      @installer.install name, version
97
      @installer.install name, Gem::Requirement.new(version)
98 98
      success = true
99 99
    rescue Gem::InstallError => e
100 100
      alert_error "Error installing #{name}:\n\t#{e.message}"
lib/rubygems/core_ext/kernel_require.rb (working copy)
4 4
# See LICENSE.txt for permissions.
5 5
#++
6 6

  
7
require 'monitor'
8

  
7 9
module Kernel
8 10

  
9 11
  if defined?(gem_original_require) then
......
31 33
  # The normal <tt>require</tt> functionality of returning false if
32 34
  # that file has already been loaded is preserved.
33 35

  
36
  ACTIVATION_MONITOR = Monitor.new
37

  
34 38
  def require path
39
    ACTIVATION_MONITOR.enter
40

  
35 41
    spec = Gem.find_unresolved_default_spec(path)
36 42
    if spec
37 43
      Gem.remove_unresolved_default_spec(spec)
......
111 117
    end
112 118

  
113 119
    raise load_error
120
  ensure
121
    ACTIVATION_MONITOR.exit
114 122
  end
115 123

  
116 124
  private :require
lib/rubygems/defaults.rb (working copy)
54 54
  # Path for gems in the user's home directory
55 55

  
56 56
  def self.user_dir
57
    File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version]
57
    parts = [Gem.user_home, '.gem', ruby_engine]
58
    parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty?
59
    File.join parts
58 60
  end
59 61

  
60 62
  ##
lib/rubygems/dependency_installer.rb (working copy)
63 63
      # HACK shouldn't change the global settings, needed for -i behavior
64 64
      # maybe move to the install command?  See also github #442
65 65
      Gem::Specification.dirs = @install_dir
66
      Gem.ensure_gem_subdirectories @install_dir
67 66
    end
68 67

  
69 68
    options = DEFAULT_OPTIONS.merge options
lib/rubygems/dependency_resolver.rb (working copy)
349 349
        when Dependency
350 350
          @dependency == other
351 351
        when DependencyRequest
352
          @dependency == other.dep && @requester == other.requester
352
          @dependency == other.dependency && @requester == other.requester
353 353
        else
354 354
          false
355 355
        end
lib/rubygems/errors.rb (working copy)
62 62
    ##
63 63
    # A wordy description of the error.
64 64
    def wordy
65
      "Found %s (%), but was for platform%s %s" %
65
      "Found %s (%s), but was for platform%s %s" %
66 66
        [@name,
67 67
         @version,
68
         @platforms.size == 1 ? 's' : '',
68
         @platforms.size == 1 ? '' : 's',
69 69
         @platforms.join(' ,')]
70 70
    end
71 71
  end
lib/rubygems/ext/ext_conf_builder.rb (working copy)
15 15
  def self.build(extension, directory, dest_path, results, args=[])
16 16
    tmp_dest = Dir.mktmpdir(".gem.", ".")
17 17

  
18
    t = nil
18 19
    Tempfile.open %w"siteconf .rb", "." do |siteconf|
20
      t = siteconf
19 21
      siteconf.puts "require 'rbconfig'"
20 22
      siteconf.puts "dest_path = #{(tmp_dest || dest_path).dump}"
21 23
      %w[sitearchdir sitelibdir].each do |dir|
......
37 39
        run cmd, results
38 40

  
39 41
        ENV["DESTDIR"] = nil
42
        ENV["RUBYOPT"] = rubyopt
43
        siteconf.unlink
40 44

  
41 45
        make dest_path, results
42 46

  
......
53 57
        ENV["DESTDIR"] = destdir
54 58
      end
55 59
    end
60
    t.unlink if t and t.path
56 61
  ensure
57 62
    FileUtils.rm_rf tmp_dest if tmp_dest
58 63
  end
lib/rubygems/gemcutter_utilities.rb (working copy)
38 38

  
39 39
    say "Enter your #{pretty_host} credentials."
40 40
    say "Don't have an account yet? " +
41
        "Create one at https://#{sign_in_host}/sign_up"
41
        "Create one at #{sign_in_host}/sign_up"
42 42

  
43 43
    email    =              ask "   Email: "
44 44
    password = ask_for_password "Password: "
......
60 60
    configured_host = Gem.host unless
61 61
      Gem.configuration.disable_default_gem_server
62 62

  
63
    @host ||= ENV['RUBYGEMS_HOST'] || configured_host
63
    @host ||=
64
      begin
65
        env_rubygems_host = ENV['RUBYGEMS_HOST']
66
        env_rubygems_host = nil if
67
          env_rubygems_host and env_rubygems_host.empty?
68

  
69
        env_rubygems_host|| configured_host
70
      end
64 71
  end
65 72

  
66 73
  def rubygems_api_request(method, path, host = nil, &block)
......
79 86
    Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
80 87
  end
81 88

  
82
  def with_response(resp)
89
  def with_response resp, error_prefix = nil
83 90
    case resp
84 91
    when Net::HTTPSuccess then
85 92
      if block_given? then
......
88 95
        say resp.body
89 96
      end
90 97
    else
91
      say resp.body
98
      message = resp.body
99
      message = "#{error_prefix}: #{message}" if error_prefix
100

  
101
      say message
92 102
      terminate_interaction 1 # TODO: question this
93 103
    end
94 104
  end
lib/rubygems/installer.rb (working copy)
331 331
  # specifications directory.
332 332

  
333 333
  def write_spec
334
    File.open(spec_file, "w") do |file|
334
    open spec_file, 'w' do |file|
335 335
      file.puts spec.to_ruby_for_cache
336
      file.fsync rescue nil # for filesystems without fsync(2)
336 337
    end
337 338
  end
338 339

  
......
773 774
  def write_build_info_file
774 775
    return if @build_args.empty?
775 776

  
776
    open spec.build_info_file, 'w' do |io|
777
    build_info_dir = File.join gem_home, 'build_info'
778

  
779
    FileUtils.mkdir_p build_info_dir
780

  
781
    build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
782

  
783
    open build_info_file, 'w' do |io|
777 784
      @build_args.each do |arg|
778 785
        io.puts arg
779 786
      end
lib/rubygems/package/old.rb (working copy)
23 23
    require 'zlib'
24 24
    Gem.load_yaml
25 25

  
26
    @gem      = gem
27
    @contents = nil
28
    @spec     = nil
26
    @contents        = nil
27
    @gem             = gem
28
    @security_policy = nil
29
    @spec            = nil
29 30
  end
30 31

  
31 32
  ##
......
142 143
      end
143 144
    end
144 145

  
145
    yaml_error = if RUBY_VERSION < '1.8' then
146
    yaml_error = if RUBY_VERSION < '1.9' then
146 147
                   YAML::ParseError
147 148
                 elsif YAML::ENGINE.yamler == 'syck' then
148 149
                   YAML::ParseError
lib/rubygems/package.rb (working copy)
336 336

  
337 337
        open destination, 'wb', entry.header.mode do |out|
338 338
          out.write entry.read
339
          out.fsync rescue nil # for filesystems without fsync(2)
340 339
        end
341 340

  
342 341
        say destination if Gem.configuration.really_verbose
lib/rubygems/platform.rb (working copy)
74 74
                      when /hpux(\d+)?/ then            [ 'hpux',      $1  ]
75 75
                      when /^java$/, /^jruby$/ then     [ 'java',      nil ]
76 76
                      when /^java([\d.]*)/ then         [ 'java',      $1  ]
77
                      when /^dalvik(\d+)?$/ then        [ 'dalvik',    $1  ]
77 78
                      when /^dotnet$/ then              [ 'dotnet',    nil ]
78 79
                      when /^dotnet([\d.]*)/ then       [ 'dotnet',    $1  ]
79 80
                      when /linux/ then                 [ 'linux',     $1  ]
......
155 156
              when /^i686-darwin(\d)/     then ['x86',       'darwin',  $1    ]
156 157
              when /^i\d86-linux/         then ['x86',       'linux',   nil   ]
157 158
              when 'java', 'jruby'        then [nil,         'java',    nil   ]
159
              when /^dalvik(\d+)?$/       then [nil,         'dalvik',  $1    ]
158 160
              when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet',  $2    ]
159 161
              when /mswin32(\_(\d+))?/    then ['x86',       'mswin32', $2    ]
160 162
              when 'powerpc-darwin'       then ['powerpc',   'darwin',  nil   ]
lib/rubygems/psych_tree.rb (working copy)
1 1
module Gem
2 2
  if defined? ::Psych::Visitors
3 3
    class NoAliasYAMLTree < Psych::Visitors::YAMLTree
4
      def self.create
5
        new({})
6
      end unless respond_to? :create
7

  
4 8
      def visit_String(str)
5 9
        return super unless str == '=' # or whatever you want
6 10

  
lib/rubygems/specification.rb (working copy)
5 5
# See LICENSE.txt for permissions.
6 6
#++
7 7

  
8
require 'rubygems/version'
9
require 'rubygems/requirement'
10
require 'rubygems/platform'
11
require 'rubygems/deprecate'
12

  
13
# :stopdoc:
14
# date.rb can't be loaded for `make install` due to miniruby
15
# Date is needed for old gems that stored #date as Date instead of Time.
16
class Date; end
17
# :startdoc:
18

  
8 19
##
9 20
# The Specification class contains the information for a Gem.  Typically
10 21
# defined in a .gemspec file or a Rakefile, and looks like this:
......
20 31
#     s.homepage    = 'https://rubygems.org/gems/example'
21 32
#   end
22 33
#
23
#   Starting in RubyGems 1.9.0, a Specification can hold arbitrary
24
#   metadata. This metadata is accessed via Specification#metadata
25
#   and has the following restrictions:
34
# Starting in RubyGems 1.9.0, a Specification can hold arbitrary
35
# metadata. This metadata is accessed via Specification#metadata
36
# and has the following restrictions:
26 37
#
27
#     * Must be a Hash object
28
#     * All keys and values must be Strings
29
#     * Keys can be a maximum of 128 bytes and values can be a
30
#       maximum of 1024 bytes
31
#     * All strings must be UTF8, no binary data is allowed
38
# * Must be a Hash object
39
# * All keys and values must be Strings
40
# * Keys can be a maximum of 128 bytes and values can be a
41
#   maximum of 1024 bytes
42
# * All strings must be UTF8, no binary data is allowed
32 43
#
33
#   For example, to add metadata for the location of a bugtracker:
44
# For example, to add metadata for the location of a bugtracker:
34 45
#
35 46
#   s.metadata = { "bugtracker" => "http://somewhere.com/blah" }
36
#
37

  
38

  
39
require 'rubygems/version'
40
require 'rubygems/requirement'
41
require 'rubygems/platform'
42
require 'rubygems/deprecate'
43

  
44
# :stopdoc:
45
# date.rb can't be loaded for `make install` due to miniruby
46
# Date is needed for old gems that stored #date as Date instead of Time.
47
class Date; end
48
# :startdoc:
49 47

  
50 48
class Gem::Specification
51 49

  
......
918 916
    result = Hash.new { |h,k| h[k] = {} }
919 917
    native = {}
920 918

  
921
    Gem::Specification._all.reverse_each do |spec|
919
    Gem::Specification.reverse_each do |spec|
922 920
      next if spec.version.prerelease? unless prerelease
923 921

  
924 922
      native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY
......
995 993
    # TODO: maybe we should switch to rubygems' version service?
996 994
    fetcher = Gem::SpecFetcher.fetcher
997 995

  
998
    latest_specs.each do |local|
996
    latest_specs(true).each do |local|
999 997
      dependency = Gem::Dependency.new local.name, ">= #{local.version}"
1000 998
      remotes, _   = fetcher.search_for_dependency dependency
1001 999
      remotes      = remotes.map { |n, _| n.version }
......
1236 1234

  
1237 1235
    unless dependency.respond_to?(:name) &&
1238 1236
           dependency.respond_to?(:version_requirements)
1239
      dependency = Gem::Dependency.new(dependency, requirements, type)
1237
      dependency = Gem::Dependency.new(dependency.to_s, requirements, type)
1240 1238
    end
1241 1239

  
1242 1240
    dependencies << dependency
......
2270 2268
        require 'rubygems/psych_tree'
2271 2269
      end
2272 2270

  
2273
      builder = Gem::NoAliasYAMLTree.new({})
2271
      builder = Gem::NoAliasYAMLTree.create
2274 2272
      builder << self
2275 2273
      ast = builder.tree
2276 2274

  
lib/rubygems.rb (working copy)
8 8
require 'rbconfig'
9 9

  
10 10
module Gem
11
  VERSION = '2.0.3'
11
  VERSION = '2.0.5'
12 12
end
13 13

  
14 14
# Must be first since it unloads the prelude from 1.9.2
......
173 173
    # require will try to activate the more specific version.
174 174

  
175 175
    spec = Gem::Specification.find_inactive_by_path path
176
    return false unless spec
176

  
177
    unless spec
178
      spec = Gem::Specification.find_by_path path
179
      return true if spec && spec.activated?
180
      return false
181
    end
177 182

  
178 183
    begin
179 184
      spec.activate
test/rubygems/test_gem.rb (working copy)
1198 1198
  end
1199 1199

  
1200 1200
  def test_self_user_dir
1201
    assert_equal File.join(@userhome, '.gem', Gem.ruby_engine,
1202
                           Gem::ConfigMap[:ruby_version]), Gem.user_dir
1201
    parts = [@userhome, '.gem', Gem.ruby_engine]
1202
    parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty?
1203

  
1204
    assert_equal File.join(parts), Gem.user_dir
1203 1205
  end
1204 1206

  
1205 1207
  def test_self_user_home
test/rubygems/test_gem_commands_help_command.rb (working copy)
10 10
    super
11 11

  
12 12
    @cmd = Gem::Commands::HelpCommand.new
13

  
14
    load File.expand_path('../rubygems_plugin.rb', __FILE__) unless
15
      Gem::Commands.const_defined? :InterruptCommand
13 16
  end
14 17

  
15 18
  def test_gem_help_bad
......
34 37
        assert_match(/\s+#{cmd}\s+\S+/, out)
35 38
      end
36 39
      assert_equal '', err
40

  
41
      refute_match 'No command found for ', out
37 42
    end
38 43
  end
39 44

  
test/rubygems/test_gem_commands_owner_command.rb (working copy)
140 140

  
141 141
    assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
142 142
  end
143

  
144
  def test_remove_owners_missing
145
    response = 'Owner could not be found.'
146
    @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
147

  
148
    use_ui @ui do
149
      @cmd.remove_owners("freewill", ["missing@example"])
150
    end
151

  
152
    assert_equal "Removing missing@example: #{response}\n", @ui.output
153
  end
154

  
143 155
end
test/rubygems/test_gem_commands_push_command.rb (working copy)
61 61
    assert_match @response, @ui.output
62 62
  end
63 63

  
64
  def test_execute
65
    open 'example', 'w' do |io| io.write 'hello' end
66

  
67
    @response = "Successfully registered gem: freewill (1.0.0)"
68
    @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK']
69

  
70
    @cmd.options[:args] = %w[example]
71

  
72
    @cmd.execute
73

  
74
    assert_equal Net::HTTP::Post, @fetcher.last_request.class
75
    assert_equal 'hello', @fetcher.last_request.body
76
    assert_equal "application/octet-stream",
77
                 @fetcher.last_request["Content-Type"]
78
  end
79

  
64 80
  def test_execute_host
65 81
    host = 'https://other.example'
66 82

  
test/rubygems/test_gem_commands_search_command.rb (working copy)
1
require 'rubygems/test_case'
2
require 'rubygems/commands/search_command'
3

  
4
class TestGemCommandsSearchCommand < Gem::TestCase
5

  
6
  def setup
7
    super
8

  
9
    @cmd = Gem::Commands::SearchCommand.new
10
  end
11

  
12
  def test_execute
13
    @cmd.handle_options %w[a]
14

  
15
    use_ui @ui do
16
      @cmd.execute
17
    end
18

  
19
    assert_match %r%REMOTE GEMS%, @ui.output
20

  
21
    assert_empty @ui.error
22
  end
23

  
24
end
25

  
test/rubygems/test_gem_commands_setup_command.rb (working copy)
1
# coding: UTF-8
2

  
1 3
require 'rubygems/test_case'
2 4
require 'rubygems/commands/setup_command'
3 5

  
......
73 75
    assert_path_exists os_defaults_rb
74 76
  end
75 77

  
78
  def test_show_release_notes
79
    @default_external = nil
80
    capture_io do
81
      @default_external, Encoding.default_external =
82
        Encoding.default_external, Encoding::US_ASCII
83
    end if Object.const_defined? :Encoding
84

  
85
    @cmd.options[:previous_version] = Gem::Version.new '2.0.2'
86

  
87
    open 'History.txt', 'w' do |io|
88
      io.puts <<-History_txt
89
# coding: UTF-8
90

  
91
=== #{Gem::VERSION} / 2013-03-26
92

  
93
* Bug fixes:
94
  * Fixed release note display for LANG=C when installing rubygems
95
  * π is tasty
96

  
97
=== 2.0.2 / 2013-03-06
98

  
99
* Bug fixes:
100
  * Other bugs fixed
101

  
102
=== 2.0.1 / 2013-03-05
103

  
104
* Bug fixes:
105
  * Yet more bugs fixed
106
      History_txt
107
    end
108

  
109
    use_ui @ui do
110
      @cmd.show_release_notes
111
    end
112

  
113
    expected = <<-EXPECTED
114
=== 2.0.2 / 2013-03-06
115

  
116
* Bug fixes:
117
  * Other bugs fixed
118

  
119
    EXPECTED
120

  
121
    assert_equal expected, @ui.output
122
  ensure
123
    capture_io do
124
      Encoding.default_external = @default_external
125
    end if @default_external
126
  end
127

  
76 128
end
77 129

  
test/rubygems/test_gem_ext_ext_conf_builder.rb (working copy)
34 34
    assert_equal "creating Makefile\n", output[1]
35 35
    assert_contains_make_command '', output[2]
36 36
    assert_contains_make_command 'install', output[4]
37
    assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb'))
37 38
  end
38 39

  
39 40
  def test_class_build_rbconfig_make_prog
......
107 108
    assert_equal("#{Gem.ruby} extconf.rb", output[0])
108 109
  end
109 110

  
111
  def test_class_build_unconventional
112
    if vc_windows? && !nmake_found?
113
      skip("test_class_build skipped - nmake not found")
114
    end
115

  
116
    File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
117
      extconf.puts <<-'EXTCONF'
118
include RbConfig
119

  
120
ruby_exe = "#{CONFIG['RUBY_INSTALL_NAME']}#{CONFIG['EXEEXT']}"
121
ruby = File.join CONFIG['bindir'], ruby_exe
122

  
123
open 'Makefile', 'w' do |io|
124
  io.write <<-Makefile
125
all: ruby
126
install: ruby
127

  
128
ruby:
129
\t#{ruby} -e0
130

  
131
  Makefile
132
end
133
      EXTCONF
134
    end
135

  
136
    output = []
137

  
138
    Dir.chdir @ext do
139
      Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
140
    end
141

  
142
    assert_contains_make_command '', output[2]
143
    assert_contains_make_command 'install', output[4]
144
    assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb'))
145
  end
146

  
110 147
  def test_class_make
111 148
    if vc_windows? && !nmake_found?
112 149
      skip("test_class_make skipped - nmake not found")
test/rubygems/test_gem_gemcutter_utilities.rb (working copy)
15 15
    @cmd.extend Gem::GemcutterUtilities
16 16
  end
17 17

  
18
  def teardown
19
    ENV['RUBYGEMS_HOST'] = nil
20
    Gem.configuration.rubygems_api_key = nil
21

  
22
    super
23
  end
24

  
18 25
  def test_alternate_key_alternate_host
19 26
    keys = {
20 27
      :rubygems_api_key => 'KEY',
......
63 70
    assert_equal 'OTHER', @cmd.api_key
64 71
  end
65 72

  
73
  def test_host
74
    assert_equal 'https://rubygems.org', @cmd.host
75
  end
76

  
77
  def test_host_RUBYGEMS_HOST
78
    ENV['RUBYGEMS_HOST'] = 'https://other.example'
79

  
80
    assert_equal 'https://other.example', @cmd.host
81
  end
82

  
83
  def test_host_RUBYGEMS_HOST_empty
84
    ENV['RUBYGEMS_HOST'] = ''
85

  
86
    assert_equal 'https://rubygems.org', @cmd.host
87
  end
88

  
66 89
  def test_sign_in
67 90
    api_key     = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
68 91
    util_sign_in [api_key, 200, 'OK']
test/rubygems/test_gem_installer.rb (working copy)
1365 1365
    refute_path_exists @spec.build_info_file
1366 1366
  end
1367 1367

  
1368
  def test_write_build_info_file_install_dir
1369
    installer = Gem::Installer.new @gem, :install_dir => "#{@gemhome}2"
1370

  
1371
    installer.build_args = %w[
1372
      --with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
1373
    ]
1374

  
1375
    installer.write_build_info_file
1376

  
1377
    refute_path_exists @spec.build_info_file
1378
    assert_path_exists \
1379
      File.join("#{@gemhome}2", 'build_info', "#{@spec.full_name}.info")
1380
  end
1381

  
1368 1382
  def test_write_cache_file
1369 1383
    cache_file = File.join @gemhome, 'cache', @spec.file_name
1370 1384
    gem = File.join @gemhome, @spec.file_name
test/rubygems/test_gem_package.rb (working copy)
335 335
  end
336 336

  
337 337
  def test_install_location_extra_slash
338
    skip 'no File.realpath on 1.8' if RUBY_VERSION < '1.9'
338 339
    package = Gem::Package.new @gem
339 340

  
340 341
    file = 'foo//file.rb'
......
511 512
      package.verify
512 513
    end
513 514

  
514
    assert_match ' - nonexistent.gem', e.message
515
    assert_match %r%^No such file or directory%, e.message
516
    assert_match %r%nonexistent.gem$%,           e.message
515 517
  end
516 518

  
517 519
  def test_verify_security_policy
test/rubygems/test_gem_spec_fetcher.rb (working copy)
132 132

  
133 133
    assert_equal 0, specs_and_sources.size
134 134
    assert_equal 1, errors.size
135
    pmm = errors.first
135 136

  
136
    assert_equal "i386-linux", errors[0].platforms.first
137
    assert_equal "i386-linux", pmm.platforms.first
138
    assert_equal "Found pl (1), but was for platform i386-linux", pmm.wordy
137 139
  end
138 140

  
139 141
  def test_spec_for_dependency_bad_fetch_spec
test/rubygems/test_gem_specification.rb (working copy)
434 434
    assert_equal expected, Gem::Specification.normalize_yaml_input(input)
435 435
  end
436 436

  
437
  def test_self_outdated
438
    util_clear_gems
439
    util_setup_fake_fetcher true
440

  
441
    a4 = quick_gem @a1.name, '4'
442
    util_build_gem a4
443
    util_setup_spec_fetcher @a1, @a2, @a3a, a4
444

  
445
    Gem::Specification.remove_spec @a1
446
    Gem::Specification.remove_spec @a2
447
    Gem::Specification.remove_spec a4
448

  
449
    assert_equal %w[a], Gem::Specification.outdated
450
  end
451

  
437 452
  DATA_PATH = File.expand_path "../data", __FILE__
438 453

  
439 454
  def test_handles_private_null_type
......
597 612
    assert @a2.activated?
598 613
  end
599 614

  
600
  def test_add_dependency_with_explicit_type
615
  def test_add_dependency_with_type
616
    gem = quick_spec "awesome", "1.0" do |awesome|
617
      awesome.add_dependency true
618
      awesome.add_dependency :gem_name
619
    end
620

  
621
    assert_equal %w[true gem_name], gem.dependencies.map { |dep| dep.name }
622
  end
623

  
624
  def test_add_dependency_with_type_explicit
601 625
    gem = quick_spec "awesome", "1.0" do |awesome|
602 626
      awesome.add_development_dependency "monkey"
603 627
    end