对不起,但这开始感觉像是在踢自己的头。我对 RSpec 完全感到困惑。一个接一个地看视频,一个接一个地阅读教程,但我仍然停留在第一个问题上。
===这是我正在使用的
http://github.com/fudgestudios/bort/tree/master
=== 错误
F
1)
NoMethodError in 'bidding on an item should work'
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:16:
spec/controllers/auction_controller_spec.rb:6:
Finished in 0.067139 seconds
1 example, 1 failure
=== 这是我的控制器动作
def bid
@bid = Bid.new(params[:bid])
@bid.save
end
===这是我的测试
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 work" do
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
凌晨 3 点起床上班,一整天一事无成,真是令人沮丧。敬请谅解。