Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/decode default part body #183

Merged
merged 3 commits into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions examples/rails4_root/spec/models/user_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'

# These two example groups are specifying the exact same behavior. However, the documentation style is different
# and the value that each one provides is different with various trade-offs. Run these examples with the specdoc
# and the value that each one provides is different with various trade-offs. Run these examples with the specdoc
# formatter to get an idea of how they differ.
# Example of documenting the behaviour explicitly and expressing the intent in the example's sentence.
describe "Signup Email", :type => :model do
Expand All @@ -10,22 +10,20 @@
include ::Rails.application.routes.url_helpers

subject { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }

it "should be delivered to the email passed in" do
is_expected.to deliver_to("jojo@yahoo.com")
end

it "should contain the user's name in the mail body" do
is_expected.to have_body_text(/Jojo Binks/)
end

it "should contain a link to the confirmation page" do
is_expected.to have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
end

it { is_expected.to have_subject(/Account confirmation/) }


end

# In this example group more of the documentation is placed in the context trying to allow for more concise specs.
Expand All @@ -44,4 +42,12 @@
it { is_expected.to deliver_to("jojo@yahoo.com") }
it { is_expected.to have_body_text(/Jojo Binks/) }
end

describe "sent with email address of 'jermain@yahoo.com', and users name 'Jermain O'Keefe'" do
let(:user_name) { "Jermain O'Keefe" }
subject { UserMailer.signup("jermain@yahoo.com", user_name) }

it { is_expected.to deliver_to("jermain@yahoo.com") }
it { is_expected.to have_body_text(user_name) }
end
end
2 changes: 1 addition & 1 deletion features/rails4_app.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ I want to verify that the example rails 4 app runs all of it's features as expec
When I run "bundle exec rake spec RAILS_ENV=test" in the rails4 app
Then I should see the following summary report:
"""
9 examples, 0 failures
11 examples, 0 failures
"""

When I run "bundle exec rake test RAILS_ENV=test" in the rails4 app
Expand Down
2 changes: 1 addition & 1 deletion lib/email_spec/mail_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def default_part
end

def default_part_body
default_part.body
HTMLEntities.new.decode(default_part.body)
end

def html
Expand Down
7 changes: 7 additions & 0 deletions spec/email_spec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ def match(object_to_test_match)
end

describe "when strings are used" do
it "should match when the body includes text with symbols" do
full_name = "Jermain O'Keefe"
email = Mail::Message.new(body: full_name)

expect(have_body_text(full_name)).to match(email)
end

it "should match when the body includes the text" do
email = Mail::Message.new(:body => 'foo bar baz')

Expand Down