0
我大部分的測試工作,但由於某些原因,FactoryGirl.build ... should_not be_valid目前不聲明RSPEC be_valid不採取行動,始終
describe "exceed the maximum number of subscriptions" do
@user = FactoryGirl.create(:user)
loop_count = GlobalVar::MAX_SUBSCRIPTIONS
loop_count.times do
@topic = FactoryGirl.create(:topic)
@subscription = FactoryGirl.create(:subscription, topic: @topic, user: @user)
end
@topic = FactoryGirl.create(:topic)
FactoryGirl.build(:subscription, topic: @topic, user: @user).should_not be_valid
end
結束工作在同規格此成功通過:
it "has a maximum length bio" do
FactoryGirl.build(:user, bio: "a"*251).should_not be_valid
end
這是我得到的錯誤的開始:我使用
(druby://192.168.1.118:53053) C:/Sites/mavens/spec/models/user_spec.rb:42:in `block (3 levels) in <top (required)>': undefined local variable or method `be_valid' for #<Class:0x7e49290> (NameError)
from (druby://192.168.1.118:53053) C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
Spork和Guard來測試。對於每次運行,我都在spec_helper中重新加載了FactoryGirl。已重新啓動spork數次,並且在重新啓動時不起作用。讓我知道,如果我的任何額外的代碼會有所幫助,並一如既往非常感謝您的幫助!
感謝Aaron ... grr在我的盡頭,但忘記了它的聲明 –