spec/mailers/notify_spec.rb not running properly?
I'm trying to add a couple of tests for some code to spec/mailers/notify_spec.rb and when I tried to fail a test on purpose to ensure that they were working properly they actually succeeded. Even adding a test with just a fail check in it passes.
I think the issue is being caused by the line:
around(:each) { ActionMailer::Base.deliveries.clear }
Which if I remove the around(:each) and place ActionMailer::Base.deliveries.clear into the before(:each) the test start to behave properly albeit with a failing test at the moment:
[steve@gitlab-dev gitlab]$ bundle exec rspec spec/mailers/notify_spec.rb
remote: Counting objects: 120, done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 120 (delta 38), reused 118 (delta 37)
Receiving objects: 100% (120/120), 300.74 KiB | 0 bytes/s, done.
Resolving deltas: 100% (38/38), done.
.....................................................................................................................F.................................
Failures:
1) Notify confirmation if email changed behaves like an email sent from GitLab has a Reply-To address
Failure/Error: expect(reply_to).to eq([gitlab_sender_reply_to])
expected: ["noreply@localhost"]
got: ["gitlab@localhost"]
(compared using ==)
Shared Example Group: "an email sent from GitLab" called from ./spec/mailers/notify_spec.rb:559
# ./spec/mailers/notify_spec.rb:35:in `block (3 levels) in <top (required)>'
Finished in 25.67 seconds
151 examples, 1 failure
Failed examples:
rspec ./spec/mailers/notify_spec.rb:33 # Notify confirmation if email changed behaves like an email sent from GitLab has a Reply-To address
In testing I found that just having an empty around(:each) section would result in success. This is running on ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux] if that makes a difference.
I was going to raise a merge request for this but wanted to get some input before I did to see if my investigation is correct and also what to do for the now failing test? I'm also wondering if there are any other tests that this might be affecting.
Thanks.