| title | Ruby SDK |
|---|---|
| description | Test email flows in RSpec, Minitest and Capybara — OTPs and magic links auto-extracted. Zero dependencies. |
gem install zerodropOr in your Gemfile:
gem "zerodrop", group: :testZero runtime dependencies. Ruby 3.0+.
require "zerodrop"
mail = ZeroDrop::Client.new
inbox = mail.generate_inbox
# => "swift-x7k29ab@zerodrop-sandbox.online"
# Trigger your app's email flow with the inbox address...
email = mail.wait_for_latest(inbox, timeout: 15)
email.otp # => "123456" — auto-extracted, no regex
email.magic_link # => "https://..." — auto-extractedRSpec.describe "Signup email verification", type: :system do
let(:mail) { ZeroDrop::Client.new }
it "verifies the account via emailed OTP" do
inbox = mail.generate_inbox
visit "/signup"
fill_in "Email", with: inbox
fill_in "Password", with: "TestPassword123!"
click_button "Create account"
email = mail.wait_for_latest(inbox, timeout: 15)
expect(email.otp).not_to be_nil
fill_in "Code", with: email.otp
click_button "Verify"
expect(page).to have_current_path("/dashboard")
end
endemail = mail.wait_for_latest(
inbox,
timeout: 15,
filter: ZeroDrop::Filter.new(
from: "noreply@yourapp.com",
has_otp: true
)
)All string filters are case-insensitive partial matches.
generate_inbox runs locally — safe with parallel_tests, flatware, turbo_tests. Every call returns a unique isolated inbox.
begin
email = mail.wait_for_latest(inbox, timeout: 15)
rescue ZeroDrop::TimeoutError
# No email arrived
rescue ZeroDrop::AuthError
# Invalid API key
rescue ZeroDrop::NetworkError => e
# Transport failure
endmail = ZeroDrop::Client.new(
api_key: ENV["ZERODROP_API_KEY"],
base_url: "https://your-instance.yourdomain.com"
)