Thanks for the clarification. For some reason, in my project the DB is not cleared and that's why I had to use an after(:each) call. It might be because my example calls a module which creates a new user instead of creating the user directly. Nevermind, I just tried in a new project and it works well. I don't know what's wrong.
<br><br>Anyway, is it normal that the following code passes:<br><br>def create_test_user<br> User.new(:first_name => 'John', :last_name => 'Doe', :email => '<a href="mailto:john@doe.fr">john@doe.fr
</a>').save<br>end<br><br>describe "A user" do<br> <br> after :each do<br> create_test_user<br> end<br> <br> it "should be created if valid" do<br> create_test_user.should be(true)<br> create_test_user.should be(false)
<br> end<br> <br> it "should not have the same email than another user" do<br> create_test_user.should be(true)<br> end<br>end<br><br><br>(Obviously if I replace after by before, then the example fail)<br>
<br>-Matt<br><br><br><br><div><span class="gmail_quote">On 5/1/07, <b class="gmail_sendername">Michael Klishin</b> <<a href="mailto:michael.s.klishin@gmail.com">michael.s.klishin@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Matt,<br><br>Second spec is not supposed to pass. You have to put the code creating<br> model in setup (before all in rspec 0.9 terms) cause DB is cleared<br>and refilled before each spec run. So this is expected behavior.
<br><br>On 02/05/07, Matt Aimonetti <<a href="mailto:mattaimonetti@gmail.com">mattaimonetti@gmail.com</a>> wrote:<br><br>> The second example fails. I'm a bit surprised that the user created by the<br>> first example doesn't exist anymore when the 2nd example tries creating a
<br>> new user.<br><br>--<br>This was freedom. Losing all hope was freedom.<br><br>Chasing the beauty in programming:<br><a href="http://www.ruby-lang.org">www.ruby-lang.org</a> | <a href="http://www.rubyonrails.org">www.rubyonrails.org
</a><br>_______________________________________________<br>rspec-devel mailing list<br><a href="mailto:rspec-devel@rubyforge.org">rspec-devel@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-devel">
http://rubyforge.org/mailman/listinfo/rspec-devel</a><br></blockquote></div><br>