-
Notifications
You must be signed in to change notification settings - Fork 23
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
Trung Lê
committed
Aug 26, 2015
1 parent
bb9f0f4
commit 9a62eb3
Showing
5 changed files
with
40 additions
and
31 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
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h1>Hello World!</h1> | ||
<%=greeting%> | ||
<%= greeting %> | ||
<p>This is a html template</p> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
This is a txt template | ||
<%=greeting%> | ||
<%= greeting %> |
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 |
---|---|---|
@@ -1,25 +1,39 @@ | ||
require 'test_helper' | ||
require 'lotus/mailer' | ||
|
||
describe Lotus::Mailer do | ||
describe 'render' do | ||
it 'renders a single template with a given format' do | ||
InvoiceMailer.new.render(:html).must_include %(<h1>Invoice template</h1>) | ||
LazyMailer.new.render(:html).must_include %(Hello World) | ||
LazyMailer.new.render(:haml).must_include %(This is a haml template) | ||
LazyMailer.new.render(:txt).must_include %(This is a txt template) | ||
describe '#render' do | ||
describe 'when template is explicitly declared' do | ||
let(:mailer) { InvoiceMailer.new } | ||
|
||
it 'renders the given template' do | ||
mailer.render(:html).must_include %(<h1>Invoice template</h1>) | ||
end | ||
end | ||
|
||
it 'renders a single template with context' do | ||
WelcomeMailer.new.render(:html).must_include %(Ahoy) | ||
WelcomeMailer.new.render(:txt).must_include %(Ahoy) | ||
describe 'when template is implicitly declared' do | ||
let(:mailer) { LazyMailer.new } | ||
|
||
it 'looks for template with same name with inflected classname and render it' do | ||
mailer.render(:html).must_include %(Hello World) | ||
mailer.render(:haml).must_include %(This is a haml template) | ||
mailer.render(:txt).must_include %(This is a txt template) | ||
end | ||
end | ||
|
||
describe 'when mailer defines context' do | ||
let(:mailer) { WelcomeMailer.new } | ||
|
||
it 'renders template with defined context' do | ||
mailer.render(:txt).must_include %(Ahoy) | ||
end | ||
end | ||
|
||
it 'renders a single template with locals' do | ||
luca = User.new('Luca') | ||
mailer = RenderMailer.new(user: luca) | ||
describe 'when locals are parsed in' do | ||
let(:mailer) { RenderMailer.new(user: User.new('Luca')) } | ||
|
||
mailer.render(:html).must_include %(Luca) | ||
it 'renders template with parsed locals' do | ||
mailer.render(:html).must_include %(Luca) | ||
end | ||
end | ||
end | ||
end |