summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-02-01 17:20:22 -0700
committermo khan <mo.khan@gmail.com>2020-02-01 17:20:22 -0700
commitc8fd92b56b07090901d1c74862c19cfc1d2df166 (patch)
tree9c2f3e9a4fc7d240511b57f7a039144eee4425a5 /spec
parentc7ded689224487abdffd15b46de063f9d03d68a1 (diff)
Add command to build index
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/build_spec.rb18
-rw-r--r--spec/unit/build_spec.rb20
-rw-r--r--spec/unit/index_spec.rb2
3 files changed, 39 insertions, 1 deletions
diff --git a/spec/integration/build_spec.rb b/spec/integration/build_spec.rb
new file mode 100644
index 0000000..691a0a4
--- /dev/null
+++ b/spec/integration/build_spec.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+RSpec.describe '`spandx build` command', type: :cli do
+ it 'executes `spandx help build` command successfully' do
+ output = `spandx help build`
+ expected_output = <<~OUT
+ Usage:
+ spandx build
+
+ Options:
+ -h, [--help], [--no-help] # Display usage information
+
+ Command description...
+ OUT
+
+ expect(output).to eq(expected_output)
+ end
+end
diff --git a/spec/unit/build_spec.rb b/spec/unit/build_spec.rb
new file mode 100644
index 0000000..5b2e9c8
--- /dev/null
+++ b/spec/unit/build_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+RSpec.describe Spandx::Commands::Build do
+ describe '#execute' do
+ subject { described_class.new(options) }
+
+ let(:output) { StringIO.new }
+ let(:options) { {} }
+
+ before do
+ end
+
+ 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: []))
+ subject.execute(output: output)
+ expect(output.string).to eq("OK\n")
+ end
+ end
+end
diff --git a/spec/unit/index_spec.rb b/spec/unit/index_spec.rb
index 1d0a7f3..fda450e 100644
--- a/spec/unit/index_spec.rb
+++ b/spec/unit/index_spec.rb
@@ -3,7 +3,7 @@
require 'tmpdir'
RSpec.describe Spandx::Index do
- subject { described_class.new(directory) }
+ subject { described_class.new(directory: directory) }
let(:directory) { Dir.mktmpdir('spandx') }