summaryrefslogtreecommitdiff
path: root/spec/unit/cli/build_spec.rb
blob: f2c6a1f574a617e69ba8652eb9d7317c0eedf506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

RSpec.describe Spandx::Cli::Commands::Build do
  subject { described_class.new(options) }

  let(:options) { {} }

  describe '#execute' do
    let(:output) { StringIO.new }

    it 'executes `build` command successfully' do
      stub_request(:get, 'https://api.nuget.org/v3/catalog0/index.json')
        .to_return(status: 200, body: JSON.generate(items: []))

      stub_request(:get, 'https://repo.maven.apache.org/maven2/.index/')
        .to_return(status: 200, body: '<html></html>')

      stub_request(:get, 'https://pypi.org/simple/')
        .to_return(status: 200, body: '<html></html>')

      stub_request(:get, 'https://index.rubygems.org/versions')
        .to_return(status: 200, body: "created_at: 2020-12-01T00:00:35+00:00\n---\n")

      subject.execute(output: output)
      expect(output.string).to eq("nuget\nmaven\npypi\nrubygems\nOK\n")
    end
  end
end