[rspec-users] My first tests, backwards. Please help

Jesse Crockett wrote:
> I hope to be on my feet after a few more basic questions..
I'm sorry, but this is beginning to feel like kicking myself in the
head.
=== here is what I'm working with
http://github.com/fudgestudios/bort/tree/master
=== Errors
FF
1)
NoMethodError in 'bidding on an item should be allowed with a credit'
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.new_record?
spec/controllers/auction_controller_spec.rb:23:
spec/controllers/auction_controller_spec.rb:6:
2)
NoMethodError in 'bidding on an item should require a credit'
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.new_record?
spec/controllers/auction_controller_spec.rb:17:
spec/controllers/auction_controller_spec.rb:6:
Finished in 0.074996 seconds
2 examples, 2 failures
=== here is my controller action
def bid
@bid = Bid.new(params[:bid])
@bid.save
end
=== here is my test
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include UsersHelper
include AuthenticatedTestHelper
describe "bidding on an item" do
controller_name :items
before(:each) do
@user = mock_user
stub!(:current_user).and_return(@user)
end
it "should require a credit" do
@user.stub!(:credits).and_return(0)
post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point
=> 1 }
assigns[:bid].should_not be_new_record
end
it "should be allowed with a credit" do
@user.stub!(:credits).and_return(1)
post 'bid', :bid => { :auction_id => 1, :user_id => @user.id, :point
=> 1 }
assigns[:bid].should be_new_record
end
end
=== spec_helper
http://github.com/fudgestudios/bort/tree/master/spec/spec_helper.rb
It's very disheartening to wake for work at 3 a.m. and accomplish
nothing for the day. Please understand.
--
Posted via http://www.ruby-forum.com/.