carbon icon indicating copy to clipboard operation
carbon copied to clipboard

be_delivered expectation fails when it shouldn't

Open jwoertink opened this issue 3 years ago • 4 comments

I have a spec that looks like this:

NewPostEmail.new(friend, me, post).should be_delivered
NewPostEmail.new(friend, me, later_post).should_not be_delivered

because I'm sending bulk emails. In this case, I want to make sure the first one is sent because post is valid for sending at this time, but later_post is not, and should not be sent out. When the spec runs, it says both should be delivered, but I think it's a false positive because it sees the same to and same subject lines and probably whatever else to determine that these are the same email even though they're not.

jwoertink avatar Mar 24 '22 18:03 jwoertink

For reference if someone wants to pick this up:

It does compare the body of the email so I'm not sure how it's failing

matthewmcgarvey avatar Mar 24 '22 20:03 matthewmcgarvey

oh, that's weird... Yeah, I wonder why it's failing :thinking:

jwoertink avatar Mar 24 '22 20:03 jwoertink

Thinking back on this, I was using dynamic templates through SendGrid https://github.com/luckyframework/carbon_sendgrid_adapter/pull/5 When using these, there isn't a body because that actually lives in SendGrid. So, the Carbon code seems to be correct, but this is a side effect to using dynamic templates where the body doesn't live in Carbon directly.

I'm not sure how to fix this, or if we even should...Spitballin maybe we could add an additional field that gets checked, but I'd say this is super low priority now.

jwoertink avatar Jul 14 '22 20:07 jwoertink

I'm no longer using the dynamic templates, and I'm still getting this failed. If I check Carbon::DevAdapter.delivered_emails.map(&.class.name), I can see the email I'm sending is in there, and if I print out which email is being sent, I can see it's my user, but it still fails.

jwoertink avatar Aug 12 '22 17:08 jwoertink