Sha256: f6d767ed970f492f92a5b1cb41e6f18fd0e644dbf3b3230e8893214f2061f31a

Contents?: true

Size: 907 Bytes

Versions: 7

Compression:

Stored size: 907 Bytes

Contents

require 'rubygems/test_case'
require 'rubygems/commands/open_command'

class TestGemCommandsOpenCommand < Gem::TestCase

  def setup
    super

    @cmd = Gem::Commands::OpenCommand.new
  end

  def gem name
    spec = quick_gem name do |gem|
      gem.files = %W[lib/#{name}.rb Rakefile]
    end
    write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
    write_file File.join(*%W[gems #{spec.full_name} Rakefile])
  end

  def test_execute
    @cmd.options[:args] = %w[foo]
    @cmd.options[:editor] = "#{Gem.ruby} -e0 --"

    gem 'foo'

    use_ui @ui do
      @cmd.execute
    end

    assert_equal "", @ui.error
  end

  def test_execute_bad_gem
    @cmd.options[:args] = %w[foo]

    assert_raises Gem::MockGemUi::TermError do
      use_ui @ui do
        @cmd.execute
      end
    end

    assert_match %r|Unable to find gem 'foo'|, @ui.output
    assert_equal "", @ui.error
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubygems-update-2.4.5 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.4.4 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.4.3 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.4.2 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.4.1 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.4.0 test/rubygems/test_gem_commands_open_command.rb
rubygems-update-2.3.0 test/rubygems/test_gem_commands_open_command.rb