Skip to content

Commit cc8d3da

Browse files
committed
add basic mailer spec features
1 parent 1ecee28 commit cc8d3da

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Feature: mailer spec
2+
3+
@rails_post_5
4+
Scenario: simple passing example
5+
Given a file named "spec/mailers/notifications_mailer_spec.rb" with:
6+
"""ruby
7+
require "rails_helper"
8+
9+
RSpec.describe NotificationsMailer, :type => :mailer do
10+
describe "notify" do
11+
let(:mail) { NotificationsMailer.signup }
12+
13+
it "renders the headers" do
14+
expect(mail.subject).to eq("")
15+
expect(mail.to).to eq(["[email protected]"])
16+
expect(mail.from).to eq(["[email protected]"])
17+
end
18+
19+
it "renders the body" do
20+
expect(mail.body.encoded).to match("Hi")
21+
end
22+
end
23+
end
24+
"""
25+
When I run `rspec spec`
26+
Then the example should pass
27+
28+
@rails_pre_5
29+
Scenario: using URL helpers without default options
30+
Given a file named "config/initializers/mailer_defaults.rb" with:
31+
"""ruby
32+
# no default options
33+
"""
34+
And a file named "spec/mailers/notifications_spec.rb" with:
35+
"""ruby
36+
require 'rails_helper'
37+
38+
RSpec.describe Notifications, :type => :mailer do
39+
let(:mail) { Notifications.signup }
40+
41+
it "renders the headers" do
42+
expect(mail.subject).to eq("Signup")
43+
expect(mail.to).to eq(["[email protected]"])
44+
expect(mail.from).to eq(["[email protected]"])
45+
end
46+
47+
it 'renders the body' do
48+
expect(mail.body.encoded).to match("Hi")
49+
end
50+
end
51+
"""
52+
When I run `rspec spec`
53+
Then the examples should all pass

0 commit comments

Comments
 (0)