Sha256: f6479689d1febb6b62d9dfca9e43eaabc021b947ae3d3c8107791fdd0c4bbc23
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
# frozen_string_literal: true describe PUNK::SendEmailWorker do let(:from) { Faker::Internet.email } let(:to) { Faker::Internet.email } let(:title) { Faker::Name.name } let(:template) { Faker::Alphanumeric.alpha } before do require "mailgun-ruby" Mailgun::Client.deliveries.clear end it "is valid with valid attributes" do expect { described_class.perform_async(from: from, to: to, subject: title, template: template) }.to change(described_class.jobs, :size).by(1) expect { described_class.drain }.not_to raise_error end it "is invalid without a from address" do expect { described_class.perform_async(to: to, subject: title, template: template) }.to change(described_class.jobs, :size).by(1) expect { described_class.drain }.to raise_error(PUNK::BadRequest, "validation failed") end it "is invalid without a to address" do expect { described_class.perform_async(from: from, subject: title, template: template) }.to change(described_class.jobs, :size).by(1) expect { described_class.drain }.to raise_error(PUNK::BadRequest, "validation failed") end it "is invalid without a subject" do expect { described_class.perform_async(from: from, to: to, template: template) }.to change(described_class.jobs, :size).by(1) expect { described_class.drain }.to raise_error(PUNK::BadRequest, "validation failed") end it "is invalid without a template" do expect { described_class.perform_async(from: from, to: to, subject: title) }.to change(described_class.jobs, :size).by(1) expect { described_class.drain }.to raise_error(PUNK::BadRequest, "validation failed") end it "sends an email" do described_class.perform_async(from: from, to: to, subject: title, template: template) described_class.drain email = Mailgun::Client.deliveries.first expect(email[:from]).to eq(from) expect(email[:subject]).to eq(title) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
punk-0.4.1 | spec/workers/punk/send_email_worker_spec.rb |