Sha256: e46abc2b77c39eeba73507dcd561a02599e3c3d21fd5242bbc596e232f7762bd

Contents?: true

Size: 1.93 KB

Versions: 4

Compression:

Stored size: 1.93 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

  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

4 entries across 4 versions & 1 rubygems

Version Path
inch-0.1.3 test/inch/cli/command/list_test.rb
inch-0.1.2 test/inch/cli/command/list_test.rb
inch-0.1.1 test/inch/cli/command/list_test.rb
inch-0.1.0 test/inch/cli/command/list_test.rb