spec/lib/crawler/cli/crawl_spec.rb [9:30]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RSpec.describe(Crawler::CLI::Crawl) do
  describe '.call' do
    let(:cli) { Dry::CLI(Crawler::CLI) }

    # Dry::CLI expects the command name to be the basename of the program
    let(:cmd) { File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME)) }

    context 'when crawl config is not provided' do
      it 'shows an error message' do
        output = capture_error { cli.call(arguments: ['crawl']) }
        expect(output).to include("ERROR: \"#{cmd} crawl\" was called with no arguments")
        expect(output).to include("Usage: \"#{cmd} crawl CRAWL_CONFIG\"")
      end
    end

    context 'when a wrong crawl config is provided' do
      let(:crawl_config) { 'spec/fixtures/non-existent-crawl.yml' }
      it 'shows an error message' do
        output = capture_output { cli.call(arguments: ['crawl', crawl_config]) }
        expect(output).to include("ERROR: Config file #{crawl_config} does not exist!")
      end
    end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



spec/lib/crawler/cli/validate_spec.rb [9:30]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RSpec.describe(Crawler::CLI::Crawl) do
  describe '.call' do
    let(:cli) { Dry::CLI(Crawler::CLI) }

    # Dry::CLI expects the command name to be the basename of the program
    let(:cmd) { File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME)) }

    context 'when crawl config is not provided' do
      it 'shows an error message' do
        output = capture_error { cli.call(arguments: ['crawl']) }
        expect(output).to include("ERROR: \"#{cmd} crawl\" was called with no arguments")
        expect(output).to include("Usage: \"#{cmd} crawl CRAWL_CONFIG\"")
      end
    end

    context 'when a wrong crawl config is provided' do
      let(:crawl_config) { 'spec/fixtures/non-existent-crawl.yml' }
      it 'shows an error message' do
        output = capture_output { cli.call(arguments: ['crawl', crawl_config]) }
        expect(output).to include("ERROR: Config file #{crawl_config} does not exist!")
      end
    end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



