Sorry, hit the enter key prematurely, That 'bit more concise' bit of the
spec should read:
describe User, "description" do
it "should not show emails" do
User.all.should be_blank
# Or, to be a bit more concise:
User.all.select{|u| u.email == '[EMAIL PROTECTED]
<[EMAIL PROTECTED]>'}.should
be_blank
end
end
On Fri, Sep 19, 2008 at 2:22 PM, Todd Tyree <[EMAIL PROTECTED]> wrote:
> I'm seeing something strange and was just wondering if someone can confirm
> my assumptions for me:
>
> I have user model with a number of specs: some of them use fixtures and
> some of them don't. Today, while talking someone through some specs that
> needed developming, I noticed that the fixtures always seemed to be
> loading. When I investigated, I discovered that it was not the fixtures
> always loading, but the db not clearing between runs. So, given a very
> simple spec (with the standard fixtures):
>
> # -*- coding: mule-utf-8 -*-
> require File.dirname(__FILE__) + '/../spec_helper'
>
> describe User do
> fixtures :users
>
> it "should have some users" do
> User.all.should_not be_blank
> end
> end
>
> describe User, "description" do
> it "should not show emails" do
> User.all.should be_blank
> # Or, to be a bit more concise:
> User.all.select{|u| u.email == '[EMAIL PROTECTED]'}.should be_blank
> end
> end
>
>
> The second describe is failing because the db is populated with the users
> from fixtures (still). I am correct in assuming, with transactions fixtures
> switched to true (as it is), this should not be the case, right?
>
> Reenforcing my feeling that this is wrong is the fact that if I include a
> before(:each) do block in the first set of statements that creates a
> non-fixture user, this user does get removed from the db before the second
> describe runs:
>
> describe User do
> fixtures :users
>
> before(:each) do
> user = User.new(:email => '[EMAIL PROTECTED]')
> user.save(false)
> end
>
> it "should have some users" do
> User.all.should_not be_blank
> end
> end
>
> # This passes
> describe User, "description" do
> it "should description" do
> User.all.select{|u| u.email == '[EMAIL PROTECTED]'}.should be_blank
> end
> end
>
--
Todd Tyree
Managing Director
Social Network Applications, Ltd.
Unit 72
49 Effra Road
London
SW2 1BZ
t 0207 733 6610
m 07861 220 182
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users