Re: [rspec-users] Support for rspec-2 and rails 2.3.x

2011-02-24 Thread David Chelimsky
On Feb 24, 2011, at 8:09 PM, Wilson Bilkovich wrote: > On Thu, Feb 24, 2011 at 8:39 AM, Ross Kaffenberger wrote: >> Anyone have rspec-2 working with rails 2.3.x? We're looking at this route as >> an incremental step towards upgrading to rails 3. >> I saw David C mention in the rpec-2 release note

Re: [rspec-users] Support for rspec-2 and rails 2.3.x

2011-02-24 Thread Wilson Bilkovich
On Thu, Feb 24, 2011 at 8:39 AM, Ross Kaffenberger wrote: > Anyone have rspec-2 working with rails 2.3.x? We're looking at this route as > an incremental step towards upgrading to rails 3. > I saw David C mention in the rpec-2 release notes this might be on the > roadmap... curious to see if there

[rspec-users] Support for rspec-2 and rails 2.3.x

2011-02-24 Thread Ross Kaffenberger
Anyone have rspec-2 working with rails 2.3.x? We're looking at this route as an incremental step towards upgrading to rails 3. I saw David C mention in the rpec-2 release notes this might be on the roadmap... curious to see if there's any progress on that front or how we can contribute. Cheer

Re: [rspec-users] RSpec doesn't see the DATA constant

2011-02-24 Thread Shamaoke
Thanks for the explanations, Costi G. I didn't thought that the `DATA` constant isn't seen by the interpreter if it is in the required file. The only solution that I can think of right now is the following: ~~~ # data_spec.rb describe 'DATA' do it 'contains lines following the __END__ keyword'

Re: [rspec-users] Stubbing Scopes

2011-02-24 Thread Christoph Schiessl
So... I settled for testing with message expectations without return values. Guess that's good enough for now. Thank you anyway! Best regards, Christoph Schiessl On Feb 15, 2011, at 21:34 , Justin Ko wrote: > > > On Feb 15, 11:14 am, Christoph Schiessl wrote: >> Thanks for your suggestion J

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] Validations aren't being performed when running 'rspec spec'

2011-02-24 Thread Craig Demyanovich
On Thu, Feb 24, 2011 at 2:07 PM, Tom Milewski wrote: > Thanks for the replies. > > Here's the error I'm seeing when running all specs (.build > and .create): > > Agent while creating should ensure that name is present > Failure/Error: Factory(:public_agent, :name => nil).should > have(1).erro

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] Validations aren't being performed when running 'rspec spec'

2011-02-24 Thread Tom Milewski
I should also note that if I replace ".should have(1).error_on(:name)" with, simply, ".should be_valid". The same issues occur. All specs (except when only running models) pass when they shouldn't be. On Feb 24, 8:48 am, David Chelimsky wrote: > On Feb 23, 2011, at 9:29 AM, Tom Milewski wrote: >

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] Validations aren't being performed when running 'rspec spec'

2011-02-24 Thread Tom Milewski
Thanks for the replies. Here's the error I'm seeing when running all specs (.build and .create): Agent while creating should ensure that name is present Failure/Error: Factory(:public_agent, :name => nil).should have(1).error_on(:name) expected 1 error on :name, got 0 # ./spec/mo

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] RSpec doesn't see the DATA constant

2011-02-24 Thread Costi G.
P. A. wrote in post #983523: > Hi. > > In Ruby there's the `DATA` constant which contains the lines following > the `__END__` keyword in the source file. For some reason RSpec > doesn't see it. > > Here's the example: > > ~~~ > # data_spec.rb > > requre 'rspec' > > describe 'DATA' do > it 'contai

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

Re: [rspec-users] Validations aren't being performed when running 'rspec spec'

2011-02-24 Thread David Chelimsky
On Feb 23, 2011, at 9:29 AM, Tom Milewski wrote: > Hello, > > When I run 'rspec spec/models' everything runs beautifully. > When I run 'rspec spec/controllers' everything also runs beautifully. > When I run 'rspec spec' the models seem to forget that the records > need to pass the validations bef

Re: [rspec-users] Validations aren't being performed when running 'rspec spec'

2011-02-24 Thread Craig Demyanovich
On Wed, Feb 23, 2011 at 10:29 AM, Tom Milewski wrote: > Model: > > validates_presence_of :name, :location, :email... > > Test: > > it "should ensure that name is present" do > Factory.build(:public_agent, :name => nil).should > have(1).error_on(:name) > end > > All of these tests do not retu