RSpec.describe TestTopic do let(:topic) { TestTopic.new } after { topic.close } context "smoke test for specs" do it "publishes and receives messages" do create_topic(topic.topic_name) topic.produce_one_message( key: "Some Key", payload: "Some Payload" ) message = topic.consume_one_message expect(message).to have_attributes( key: "Some Key", payload: "Some Payload" ) end it "receives returns nil when no messages are received" do create_topic(topic.topic_name) consumer = topic.consumer message = consumer.poll(1) expect(message).to be(nil) end end context "spec helpers" do it "creates topics" do create_topic(topic.topic_name) expect(list_topics).to include(topic.topic_name) end it "deletes topics" do create_topic(topic.topic_name) delete_topic(topic.topic_name) expect(list_topics).not_to include(topic.topic_name) end end end