Sha256: 89ed08cf5a25d266a239ac88967403b26bf00a844ce7f659e98cadb7af9f8c83

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

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

describe ::Inch::CLI::Command::Suggest do
  before do
    Dir.chdir fixture_path(:simple)
    @command = ::Inch::CLI::Command::Suggest
  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::Bar#method_with_wrong_doc\b/, out
    assert_match /\bFoo::Bar#method_without_docstring\b/, out
    assert_match /\bFoo::Bar#method_with_unstructured_doc\b/, out
  end

  it "should run with --pedantic switch" do
    out, err = capture_io do
      @command.run("--pedantic")
    end
    refute out.empty?, "there should be some output"
    assert err.empty?, "there should be no errors"
  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::Bar#method_with_wrong_doc\b/, out
    assert_match /\bFoo::Bar#method_without_docstring\b/, out
    assert_match /\bFoo::Bar#method_with_unstructured_doc\b/, out
  end

  it "should run with non-existing filelist in args" do
    out, err = capture_io do
      @command.run("app/**/*.rb")
    end
    # TODO: not sure what should actually happen here:
    #   no output or error message?
    #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.+suggest/, out
    assert err.empty?, "there should be no errors"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inch-0.1.1 test/inch/cli/command/suggest_test.rb
inch-0.1.0 test/inch/cli/command/suggest_test.rb