Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
@Pat: thanks for the suggestions. It's perhaps not only what David suggested -- I seem to be suffering from some cached AR value. I changed my constant declaration to: RESIDENTIAL = find_or_create_by_name("residential") This keeps the number of instances down to a 1. That's good. But if I

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
SOLVED -- it was an AR caching problem. I had Factory code that was essentially doing: def make_me_a_premise(opts = {}) opts = MODEL_PREMISE_DEFAULTS.merge(opts) premise = Factory(:premise) Factory(:premise_group_member, :premise => premise, :premise_group =>

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread David Chelimsky
On Feb 24, 2011, at 12:58 PM, Fearless Fool wrote: > David Chelimsky wrote in post #983690: >>> RESIDENTIAL = self.create(:name => "residential") >> ^^ this is probably the problem ^^ >> ... > > Ah! got it. FWIW, I wrote a query to the Rails group several months > ago wondering if this cons

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
David Chelimsky wrote in post #983690: >>RESIDENTIAL = self.create(:name => "residential") > ^^ this is probably the problem ^^ > ... Ah! got it. FWIW, I wrote a query to the Rails group several months ago wondering if this construct was legit and got feedback that it was legit. Your expl

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
yet more info... The two errors appear to be closely related. When run as individual files, PremiseGroup#premises is returning expected values. When run together, premise_group.premises returns "phantom" premises (which show up as nil values). For test B, the phantoms causes the count to b

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Pat Maddox
cattr_accessor, class vars / class instance vars, constants, globals...all things that maintain state across test runs, and so could lead to errors like this. I'd start looking there. Pat On Feb 24, 2011, at 9:55 AM, Fearless Fool wrote: > I'm baffled. If I do: > > $ bundle exec ruby -S r

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
David Chelimsky wrote in post #983675: > On Feb 24, 2011, at 11:55 AM, Fearless Fool wrote: > What are the failures you're seeing? When running A before B, B's assertion that: @common_options[:premise_group].premises.size.should == 3 fails because premise_group.premises.size == 5 (even though on

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread David Chelimsky
On Feb 24, 2011, at 12:36 PM, Fearless Fool wrote: > A little additional information: every time I run the tests, it creates > a new PremiseGroup model. Shouldn't the db get rolled back between > tests? > > Here is PremiseGroup, listed here in its entirety: > > class PremiseGroup < ActiveRec

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
A little additional information: every time I run the tests, it creates a new PremiseGroup model. Shouldn't the db get rolled back between tests? Here is PremiseGroup, listed here in its entirety: class PremiseGroup < ActiveRecord::Base has_many :premise_group_members, :dependent => :des

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread David Chelimsky
On Feb 24, 2011, at 11:55 AM, Fearless Fool wrote: > I'm baffled. If I do: > > $ bundle exec ruby -S rspec --tty A_spec.rb > $ bundle exec ruby -S rspec --tty B_spec.rb > > I get no errors. But then if I do: > > $ bundle exec ruby -S rspec --tty A_spec.rb B_spec.rb > > I get an error o

[rspec-users] ordering dependency in tests?

2011-02-24 Thread Fearless Fool
I'm baffled. If I do: $ bundle exec ruby -S rspec --tty A_spec.rb $ bundle exec ruby -S rspec --tty B_spec.rb I get no errors. But then if I do: $ bundle exec ruby -S rspec --tty A_spec.rb B_spec.rb I get an error on B_spec. And if I reverse the order: $ bundle exec ruby -S rspe