Skip to content

Commit

Permalink
Add a basic test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 26, 2024
1 parent 3506235 commit 7434f7b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fixtures/async/discord/client_context.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "async/discord/client"
require "sus/fixtures/async/reactor_context"

module Async
module Discord
DISCORD_BOT_TOKEN = ENV.fetch("DISCORD_BOT_TOKEN")

ClientContext = Sus::Shared("client context") do
include Sus::Fixtures::Async::ReactorContext

def authenticated_client
client = Async::Discord::Client.open

return client.authenticated(bot: DISCORD_BOT_TOKEN)
end

let(:client) {authenticated_client}
end
end
end
3 changes: 3 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
gem "rubocop"

gem "sus-fixtures-async-http"

gem "bake-test"
gem "bake-test-external"
end
4 changes: 4 additions & 0 deletions lib/async/discord/guilds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def each(&block)
def to_a
each.to_a
end

def empty?
self.value.empty?
end
end
end
end
14 changes: 14 additions & 0 deletions test/async/discord/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "async/discord/client_context"

describe Async::Discord::Client do
include Async::Discord::ClientContext

with "#guilds" do
it "can list guilds" do
guilds = client.guilds

expect(guilds).to be_a(Async::Discord::Guilds)
expect(guilds).not.to be(:empty?)
end
end
end

0 comments on commit 7434f7b

Please # to comment.