diff --git a/fixtures/async/discord/client_context.rb b/fixtures/async/discord/client_context.rb new file mode 100644 index 0000000..9e2819f --- /dev/null +++ b/fixtures/async/discord/client_context.rb @@ -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 diff --git a/gems.rb b/gems.rb index 7fc4437..d8c9aff 100644 --- a/gems.rb +++ b/gems.rb @@ -22,4 +22,7 @@ gem "rubocop" gem "sus-fixtures-async-http" + + gem "bake-test" + gem "bake-test-external" end diff --git a/lib/async/discord/guilds.rb b/lib/async/discord/guilds.rb index b8f309b..3f67280 100644 --- a/lib/async/discord/guilds.rb +++ b/lib/async/discord/guilds.rb @@ -27,6 +27,10 @@ def each(&block) def to_a each.to_a end + + def empty? + self.value.empty? + end end end end diff --git a/test/async/discord/client.rb b/test/async/discord/client.rb new file mode 100644 index 0000000..d68dd66 --- /dev/null +++ b/test/async/discord/client.rb @@ -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