Skip to content

Commit

Permalink
subkingdoms endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Feb 28, 2024
1 parent 577d110 commit dc9dc04
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/plants/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'plants/resources/genus'
require 'plants/resources/kingdoms'
require 'plants/resources/plants'
require 'plants/resources/subkingdoms'

module Plants
# Resources 'container' module
Expand All @@ -10,5 +11,6 @@ module Resources
include Genus
include Kingdoms
include Plants
include Subkingdoms
end
end
19 changes: 19 additions & 0 deletions lib/plants/resources/subkingdoms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Plants
module Resources
# Subkingdoms module
# @see https://docs.trefle.io/reference#tag/Subkingdoms
module Subkingdoms
# GET /subkingdoms
# @return [::HTTP::Response]
def list_subkingdoms
client.get('subkingdoms')
end

# @param kingdom [String]
# @return [::HTTP::Response]
def find_subkingdom(kingdom)
client.get("subkingdoms/#{kingdom}")
end
end
end
end
28 changes: 28 additions & 0 deletions spec/plants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,32 @@
expect(a_request(:get, "#{Plants::Client::URL}/kingdoms/foobar")).to have_been_made
end
end

describe '.list_subkingdoms' do
before(:each) do
stub_request(:get, "#{Plants::Client::URL}/subkingdoms")
.to_return(status: 200, body: '{}')
end

subject { Plants.list_subkingdoms }

it do
expect(subject).to be_instance_of(HTTP::Response)
expect(a_request(:get, "#{Plants::Client::URL}/subkingdoms")).to have_been_made
end
end

describe '.find_subkingdom' do
before(:each) do
stub_request(:get, "#{Plants::Client::URL}/subkingdoms/foobar")
.to_return(status: 200, body: '{}')
end

subject { Plants.find_subkingdom('foobar') }

it do
expect(subject).to be_instance_of(HTTP::Response)
expect(a_request(:get, "#{Plants::Client::URL}/subkingdoms/foobar")).to have_been_made
end
end
end

0 comments on commit dc9dc04

Please sign in to comment.