Sha256: bc770030e3c87e237738a7bd85513302679f5878ae6bb0b54df2450edc62712c

Contents?: true

Size: 1.96 KB

Versions: 5

Compression:

Stored size: 1.96 KB

Contents

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

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

  include BaseListTests

  it "should run without args" do
    out, err = capture_io do
      @command.run()
    end
    refute out.empty?, "there should be some output"
    assert err.empty?, "there should be no errors"
    assert_match /\bFoo\b/, out
    assert_match /\bFoo::Bar\b/, out
    assert_match /\bFoo::Bar#method_with_full_doc\b/, out
    assert_match /\bFoo::Bar#method_with_code_example\b/, out
  end

  it "should run with --numbers switch" do
    out, err = capture_io do
      @command.run("--numbers")
    end
    refute out.empty?, "there should be some output"
    assert err.empty?, "there should be no errors"
    assert_match /\bFoo\b/, out
    assert_match /\bFoo::Bar\b/, out
    assert_match /\bFoo::Bar#method_with_full_doc\b/, out
    assert_match /\bFoo::Bar#method_with_code_example\b/, out
  end

  it "should run with filelist in args" do
    out, err = capture_io do
      @command.run("lib/**/*.rb", "app/**/*.rb")
    end
    refute out.empty?, "there should be some output"
    assert err.empty?, "there should be no errors"
    assert_match /\bFoo\b/, out
    assert_match /\bFoo::Bar\b/, out
    assert_match /\bFoo::Bar#method_with_full_doc\b/, out
    assert_match /\bFoo::Bar#method_with_code_example\b/, out
  end

  it "should run with non-existing filelist in args" do
    out, err = capture_io do
      @command.run("app/**/*.rb")
    end
    assert out.empty?, "there should be no output"
    assert err.empty?, "there should be no errors"
  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.+list/, out
    assert err.empty?, "there should be no errors"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inch-0.2.3 test/inch/cli/command/list_test.rb
inch-0.2.2 test/inch/cli/command/list_test.rb
inch-0.2.1 test/inch/cli/command/list_test.rb
inch-0.2.0 test/inch/cli/command/list_test.rb
inch-0.1.4 test/inch/cli/command/list_test.rb