-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some specs to get to 100% coverage
- Loading branch information
Showing
3 changed files
with
356 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,73 @@ | ||
RSpec.describe Foobara::HttpApiCommand do | ||
it "has a version number" do | ||
expect(Foobara::HttpApiCommand::VERSION).to_not be_nil | ||
RSpec.describe Foobara::HttpApiGetCommand do | ||
describe "#run" do | ||
context "when command hits rubygems search API" do | ||
let(:command_class) do | ||
mixin = described_class | ||
|
||
stub_class(:Search, Foobara::Command) do | ||
include mixin | ||
|
||
inputs do | ||
query :string, :required | ||
end | ||
|
||
result [Hash] | ||
|
||
url "https://rubygems.org/api/v1/search.json" | ||
|
||
def build_request_body | ||
self.request_body = { query: } | ||
end | ||
end | ||
end | ||
|
||
let(:command) { command_class.new(inputs) } | ||
let(:outcome) { command.run } | ||
let(:result) { outcome.result } | ||
let(:errors) { outcome.errors } | ||
let(:errors_hash) { outcome.errors_hash } | ||
|
||
let(:inputs) do | ||
{ query: "foobara" } | ||
end | ||
|
||
it "is successful", vcr: { record: :none } do | ||
expect(outcome).to be_success | ||
expect(result).to be_an(Array) | ||
end | ||
end | ||
|
||
context "when command hits rubygems versions API" do | ||
let(:command_class) do | ||
mixin = described_class | ||
|
||
stub_class(:GetVersions, Foobara::Command) do | ||
include mixin | ||
|
||
inputs do | ||
gem_name :string, :required | ||
end | ||
|
||
result [Hash] | ||
|
||
url { "https://rubygems.org/api/v1/versions/#{gem_name}.json" } | ||
end | ||
end | ||
|
||
let(:command) { command_class.new(inputs) } | ||
let(:outcome) { command.run } | ||
let(:result) { outcome.result } | ||
let(:errors) { outcome.errors } | ||
let(:errors_hash) { outcome.errors_hash } | ||
|
||
let(:inputs) do | ||
{ gem_name: "foobara" } | ||
end | ||
|
||
it "is successful", vcr: { record: :none } do | ||
expect(outcome).to be_success | ||
expect(result).to be_an(Array) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.