[rspec-devel] names for setup and teardown methods

Matt Aimonetti mattaimonetti at gmail.com
Wed May 2 14:36:12 EDT 2007

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.

Anyway, is it normal that the following code passes:

def create_test_user
  User.new(:first_name => 'John', :last_name => 'Doe', :email => '
john at doe.fr').save

describe "A user" do

  after :each do

  it "should be created if valid" do
    create_test_user.should be(true)
    create_test_user.should be(false)

  it "should not have the same email than another user" do
   create_test_user.should be(true)

(Obviously if I replace after by before, then the example fail)


On 5/1/07, Michael Klishin <michael.s.klishin at gmail.com> wrote:
> Matt,
> Second spec is not supposed to pass. You have to put the code creating
> model in setup (before all in rspec 0.9 terms) cause DB is cleared
> and refilled before each spec run. So this is expected behavior.
> On 02/05/07, Matt Aimonetti <mattaimonetti at gmail.com> wrote:
> > The second example fails. I'm a bit surprised that the user created by
> the
> > first example doesn't exist anymore when the 2nd example tries creating
> a
> > new user.
> --
> This was freedom. Losing all hope was freedom.
> Chasing the beauty in programming:
> www.ruby-lang.org | www.rubyonrails.org
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20070502/3b6f1b62/attachment-0001.html 

More information about the rspec-devel mailing list