[rspec-users] why does "ruby <spec_file>" work, but "rake spec" give spec errors?

David Chelimsky dchelimsky at gmail.com
Tue Dec 23 23:01:29 EST 2008


On Tue, Dec 23, 2008 at 10:53 PM, Greg Hauptmann
<greg.hauptmann.ruby at gmail.com> wrote:
> PSS.  Note sure why, however now it seems "rake spec" is working.  Did make
> some minor changes to the spec but nothing I would have thought that would
> have solved this...ummm

What changes?

>
> On Wed, Dec 24, 2008 at 11:56 AM, Greg Hauptmann
> <greg.hauptmann.ruby at gmail.com> wrote:
>>
>> PS.  I do call the method in a before(:each)...
>>
>> ------------------------
>> describe Recurring, '.add_projections (interest)' do
>>   include RecurringSpecHelper
>>
>>   before(:each) do
>>     load_bank_account_base_fixtures  # <=== Called Here
>>     @destn_bank.should_not be_nil
>> .
>> .
>> .
>> ------------------------
>>
>> On Wed, Dec 24, 2008 at 11:54 AM, Greg Hauptmann
>> <greg.hauptmann.ruby at gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> Here's an example (below) of the errors I get when I run "rake spec",
>>> however they don't occur when I run "spec <specfile>".   The issue seems to
>>> be that when I call a help method which is "included" there is a point it
>>> adds an interest rate row to a table.  In the successful case it appears
>>> this works, but in the unsuccessful case it seems the row didn't get
>>> created.
>>>
>>> Doesn't rspec clean out the database between each test?  (i.e. like for
>>> each:  it "should do X")  Just trying to understand how things could clash?
>>>
>>>
>>> 1)
>>> 'Recurring.add_projections (interest) should raise exception if recurring
>>> items specifies person_id how-ever amount fields are invalid' FAILED
>>> expected: 8.0,
>>>      got: nil (using ==)
>>> ./spec/models/recurring/projections_spec.rb:330:
>>>
>>> 2)
>>> 'Recurring.add_projections (interest) should put allocation in place when
>>> recurring item specifies person_id & amount fields valid' FAILED
>>> expected: 8.0,
>>>      got: nil (using ==)
>>> ./spec/models/recurring/projections_spec.rb:330:
>>>
>>>
>>>   def load_bank_account_base_fixtures
>>>     lambda {BankAccount.delete_all}.should_not raise_error
>>>     @destn_bank = BankAccount.new(:name => "Bank_Destn", :active => true)
>>>     @destn_bank.save!
>>>     ir = InterestRate.new(:rate => 8.0,         # <== SEEMS THIS ISN'T
>>> THERE FOR UNSUCCESSFUL CASE
>>>       :start_date => Time.now.to_date.years_ago(1),
>>>       :bank_account_id => @destn_bank.id
>>>     )
>>>     ir.save!
>>>   end
>>>
>>> thanks
>>>
>>>
>>> On Wed, Dec 24, 2008 at 11:33 AM, David Chelimsky <dchelimsky at gmail.com>
>>> wrote:
>>>>
>>>> On Tue, Dec 23, 2008 at 8:29 PM, Greg Hauptmann
>>>> <greg.hauptmann.ruby at gmail.com> wrote:
>>>> > Hi,
>>>> >
>>>> > Does anyone know why I would have some spec's failing when using
>>>> > "./script/autospec" or "rake spec", however when I just run them using
>>>> > "ruby
>>>> > <spec file>" it passes ok"?   What's the difference in kicking off a
>>>> > spec by
>>>> > these different means?
>>>>
>>>> This is typically due to some accidental dependencies between examples.
>>>>
>>>> What sorts of failures are you getting?
>>>>
>>>> >
>>>> > Only thing that comes to mind is perhaps using "ruby <spec file>" is
>>>> > maybe
>>>> > working in the development environment not the test environment?
>>>> >  However I
>>>> > have tried running "rake db:migrate RAILS_ENV=test", as well as doing
>>>> > a
>>>> > "rake db:test:purge" and then "rake db:test:prepare"...
>>>> >
>>>> > Thanks
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > rspec-users mailing list
>>>> > rspec-users at rubyforge.org
>>>> > http://rubyforge.org/mailman/listinfo/rspec-users
>>>> >
>>>> _______________________________________________
>>>> rspec-users mailing list
>>>> rspec-users at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list