~ubuntu-branches/debian/sid/ruby-cri/sid

« back to all changes in this revision

Viewing changes to test/test_command.rb

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2014-04-14 15:15:48 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140414151548-xni482c106hiik3q
Tags: 2.6.0-1
* Imported Upstream version 2.6.0
* Add asciidoctor to Build-Depends, now that the README file has a .adoc
  extension
* Add privacy-breach.patch to remove remote badges from the README file

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
      description 'Sinks stuff (like ships and the like).'
86
86
 
87
87
      run do |opts, args|
88
 
        $stdout.puts "Sinking!"
89
88
      end
90
89
    end
91
90
 
424
423
    assert_match(pattern, cmd.help(:verbose => true))
425
424
  end
426
425
 
 
426
  def test_run_with_raw_args
 
427
    cmd = Cri::Command.define do
 
428
      name 'moo'
 
429
      run do |opts, args|
 
430
        puts "args=#{args.join(',')} args.raw=#{args.raw.join(',')}"
 
431
      end
 
432
    end
 
433
 
 
434
    out, err = capture_io_while do
 
435
      cmd.run(%w( foo -- bar ))
 
436
    end
 
437
    assert_equal "args=foo,bar args.raw=foo,--,bar\n", out
 
438
  end
 
439
 
 
440
  def test_run_without_block
 
441
    cmd = Cri::Command.define do
 
442
      name 'moo'
 
443
    end
 
444
 
 
445
    assert_raises(Cri::NotImplementedError) do
 
446
      cmd.run([])
 
447
    end
 
448
  end
 
449
 
 
450
  def test_runner_with_raw_args
 
451
    cmd = Cri::Command.define do
 
452
      name 'moo'
 
453
      runner(Class.new(Cri::CommandRunner) do
 
454
        def run
 
455
          puts "args=#{arguments.join(',')} args.raw=#{arguments.raw.join(',')}"
 
456
        end
 
457
      end)
 
458
    end
 
459
 
 
460
    out, err = capture_io_while do
 
461
      cmd.run(%w( foo -- bar ))
 
462
    end
 
463
    assert_equal "args=foo,bar args.raw=foo,--,bar\n", out
 
464
  end
 
465
 
 
466
  def test_compare
 
467
    foo = Cri::Command.define { name 'foo' }
 
468
    bar = Cri::Command.define { name 'bar' }
 
469
    qux = Cri::Command.define { name 'qux' }
 
470
 
 
471
    assert_equal [ bar, foo, qux ], [ foo, bar, qux ].sort
 
472
  end
 
473
 
427
474
end