Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0dcbca
commit 831ba99
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "spec_helper" | ||
require "support/rails_app" | ||
require "rspec/rails" | ||
require "action_mailer" | ||
|
||
class BirdsMailer < ActionMailer::Base | ||
end | ||
|
||
RSpec.describe BirdsMailer, type: :mailer do | ||
let(:bird){ double :bird } | ||
let(:birds) { double :birds } | ||
|
||
context "when birds relation is exposed" do | ||
class BirdsMailer | ||
expose(:birds, -> { Bird.all }) | ||
|
||
def hello_birds | ||
mail { |format| format.text { render plain: "Hello #{birds}" } } | ||
end | ||
end | ||
|
||
it "sends the email with exposed birds" do | ||
expect(Bird).to receive(:all).and_return(birds) | ||
expect(described_class.hello_birds.body.to_s) | ||
.to include("Hello #{birds}") | ||
end | ||
end | ||
|
||
context "when bird is exposed" do | ||
class BirdsMailer | ||
attr_accessor :bird_id | ||
expose(:bird, id: -> { bird_id }) | ||
|
||
def hello_bird(id) | ||
self.bird_id = id | ||
mail { |format| format.text { render plain: "Hello #{bird}" } } | ||
end | ||
end | ||
|
||
it "sends the email with exposed bird" do | ||
expect(Bird).to receive(:find).with('some-id').and_return(bird) | ||
expect(described_class.hello_bird('some-id').body.to_s) | ||
.to include("Hello #{bird}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ def routes | |
end | ||
end | ||
|
||
def self.root | ||
'' | ||
end | ||
|
||
def self.application | ||
@app ||= App.new | ||
end | ||
|