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

Support the specified name and address for bcc_to and cc_to matchers #212

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
4 changes: 2 additions & 2 deletions lib/email_spec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def description

def matches?(email)
@email = email
@actual_recipients = address_array{ email.bcc }.sort
@actual_recipients = address_array { email[:bcc].formatted }.sort
@actual_recipients == @expected_email_addresses
end

Expand Down Expand Up @@ -162,7 +162,7 @@ def description

def matches?(email)
@email = email
@actual_recipients = address_array { email.cc }.sort
@actual_recipients = address_array { email[:cc].formatted }.sort
@actual_recipients == @expected_email_addresses
end

Expand Down
12 changes: 12 additions & 0 deletions spec/email_spec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ def match(object_to_test_match)
expect(bcc_to("jimmy_bean@yahoo.com")).to match(email)
end

it "should match when the email is set to deliver to the specified name and address" do
email = Mail::Message.new(:bcc => "Jimmy Bean <jimmy_bean@yahoo.com>")

expect(bcc_to("Jimmy Bean <jimmy_bean@yahoo.com>")).to match(email)
end

it "should match when a list of emails is exact same as all of the email's recipients" do
email = Mail::Message.new(:bcc => ["james@yahoo.com", "karen@yahoo.com"])

Expand Down Expand Up @@ -214,6 +220,12 @@ def match(object_to_test_match)
expect(cc_to("jimmy_bean@yahoo.com")).to match(email)
end

it "should match when the email is set to deliver to the specified name and address" do
email = Mail::Message.new(:cc => "Jimmy Bean <jimmy_bean@yahoo.com>")

expect(cc_to("Jimmy Bean <jimmy_bean@yahoo.com>")).to match(email)
end

it "should match when a list of emails is exact same as all of the email's recipients" do
email = Mail::Message.new(:cc => ["james@yahoo.com", "karen@yahoo.com"])

Expand Down