padrino/padrino-framework — Issue #735: Padrino + Capybara + mailer + (selenium | webkit)
Author: philly-mac
Created: 2011-12-20 15:32:34+00:00
State: open

I have noticed that when I use capybara to run tests and I use selenium or webit to test javascript, and the test hits a controller that creates an object, and that method also calls the mailer, the method is called multiple times. Meaning that I can multiple objects created when I was just expecting 1.

My testing stack is

Bacon
Capybara
Selenium or Webkit
rr

Now when I mock the calls to the mailer with something like

````
stub(MyApp).deliver
````

Then things work as they should.
But when this is not there and I put some simple debug in there like

````
puts "HERE 1"
if @user.save
puts "HERE 2"
MyApp.deliver(:user,:confirm, @user)
....
````

What I see is

````
HERE 1
HERE 2
HERE 1
HERE 2
HERE 1
HERE 2
````

When I mock I get what I expect

````
HERE 1
HERE 2
````

So, is this expected behaviour? Are the mailers supposed to be mocked out?
I was hoping to test full functionality, but with this bug/limitation I cannot.
What is the mailer call is making the action to be called multiple times?

Any ideas on this one?