I have a model with an observer that emails out upon creation, and I
want to do some testing of emails that get generated via various
actions...  So I was hoping I could do:

# spec_helper.rb

config.before(:each) do
  ActionMailer::base.deliveries.clear
end

# my_phat_observer_spec.rb

let!(:yo_momma) { create_yo_momma }

describe "after_update" do
  it "sends an email when it knows your daddy" do
    expect { yo_momma.update_attribute(:daddy => create_daddy) }.to
change(ActionMailer::Base, :deliveries).by(1)
  end
end

...


However, inside that example group, ActionMailer::Base.deliveries is populated 
from the create_yo_momma
method-- before the expectation is even declared.

Is there a way to make a config.before(:each) that actually runs as the
*LAST* before callback prior to the actual example group?

Thank you.

Patrick J. Collins
http://collinatorstudios.com

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to