Sha256: beb86bf990d5ad698e36bf675735fe95da4a40ce211e5d011122f6955d6e947c

Contents?: true

Size: 924 Bytes

Versions: 9

Compression:

Stored size: 924 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/cli'

class TestCLICommandParser < Minitest::Test

  class SampleCommand < CmdParse::Command
    def initialize
      super('sample', takes_commands: false)
    end
  end

  def setup
    @cli = Webgen::CLI::CommandParser.new
  end

  def test_initialize
    assert_equal(Logger::INFO, @cli.log_level)
    assert_nil(@cli.directory)
  end

  def test_website
    assert_equal(Dir.pwd, @cli.website.directory)
    assert_equal(@cli, @cli.website.ext.cli)
  end

  def test_parse
    @cli.website.ext.cli.add_command(SampleCommand.new)
    out, _err = capture_io do
      begin
        @cli.parse(['help'])
        assert_equal(Dir.pwd, @cli.directory)
      rescue SystemExit
      end
    end
    assert_match(/Global Options:/, out)
    assert_match(/create.*generate.*help.*install.*sample.*.*show.*config.*deps.*extensions.*version/m, out)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/test_cli.rb
webgen-1.7.2 test/webgen/test_cli.rb
webgen-1.7.1 test/webgen/test_cli.rb
webgen-1.7.0 test/webgen/test_cli.rb
webgen-1.6.0 test/webgen/test_cli.rb
webgen-1.5.2 test/webgen/test_cli.rb
webgen-1.5.1 test/webgen/test_cli.rb
webgen-1.5.0 test/webgen/test_cli.rb
webgen-1.4.1 test/webgen/test_cli.rb