Sha256: 6d7e0e4112a66f2cacb9f6fbab1fb82cd4280f33e0c2071d9ccc9bbb56c6004b

Contents?: true

Size: 1.9 KB

Versions: 28

Compression:

Stored size: 1.9 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')

describe ::Inch::CLI::Command::Show do
  before do
    Dir.chdir fixture_path(:ruby, :simple)
    @command = ::Inch::CLI::Command::Show
  end

  it 'should warn and exit when run without args' do
    out, err = capture_io do
      assert_raises(SystemExit) { @command.run }
    end
    assert out.empty?, 'there should be no output'
    refute err.empty?, 'there should be some error message'
  end

  it 'should output info when run with --help' do
    out, err = capture_io do
      assert_raises(SystemExit) { @command.run('--help') }
    end
    refute out.empty?, 'there should be some output'
    assert_match(/\bUsage\b.+show/, out)
    assert err.empty?, 'there should be no errors'
  end

  it 'should output some info when run with a definitive object name' do
    out, err = capture_io do
      @command.run('Foo::Bar#method_with_full_doc', '--no-color')
    end
    refute out.empty?, 'there should be some output'
    assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
    refute_match(/\b Foo::Bar#method_without_doc\b/, out)
    assert err.empty?, 'there should be no errors'
  end

  it 'should output all children info when run with a partial name' do
    out, err = capture_io do
      @command.run('Foo::Bar#', '--no-color')
    end
    refute out.empty?, 'there should be some output'
    assert_match(/\bFoo::Bar#method_without_doc\b/, out)
    assert_match(/\bFoo::Bar#method_with_full_doc\b/, out)
    assert err.empty?, 'there should be no errors'
  end

  it 'should output colored information' do
    out, _err = capture_io do
      @command.run('Foo::Bar#')
    end
    refute_equal out.uncolor, out, 'should be colored'
  end

  it 'should output uncolored information when asked' do
    out, _err = capture_io do
      @command.run('Foo::Bar#', '--no-color')
    end
    assert_equal out.uncolor, out, 'should not be colored'
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
inch-0.6.4 test/integration/cli/command/show_test.rb
inch-0.6.3 test/integration/cli/command/show_test.rb
inch-0.6.2 test/integration/cli/command/show_test.rb
inch-0.6.1 test/integration/cli/command/show_test.rb
inch-0.6.0 test/integration/cli/command/show_test.rb
inch-0.6.0.rc6 test/integration/cli/command/show_test.rb
inch-0.6.0.rc5 test/integration/cli/command/show_test.rb
inch-0.6.0.rc4 test/integration/cli/command/show_test.rb
inch-0.6.0.rc3 test/integration/cli/command/show_test.rb
inch-0.6.0.rc2 test/integration/cli/command/show_test.rb
inch-0.6.0.rc1 test/integration/cli/command/show_test.rb
inch-0.5.10 test/integration/cli/command/show_test.rb
inch-0.5.9 test/integration/cli/command/show_test.rb
inch-0.5.8 test/integration/cli/command/show_test.rb
inch-0.5.7 test/integration/cli/command/show_test.rb
inch-0.5.6 test/integration/cli/command/show_test.rb
inch-0.5.5 test/integration/cli/command/show_test.rb
inch-0.5.4 test/integration/cli/command/show_test.rb
inch-0.5.3 test/integration/cli/command/show_test.rb
inch-0.5.2 test/integration/cli/command/show_test.rb