我已經在Rails中開始了我的TDD之旅,並且遇到了一個關於模型驗證測試的小問題,我似乎找不到解決方案。比方說,我有一個用戶模式, class User < ActiveRecord::Base
validates :username, :presence => true
end
和一個簡單的測試 it "should require a username" do
Use
我有一個非常基本的管理模式: class Admin < ActiveRecord::Base
has_secure_password
validates_uniqueness_of :email
attr_accessible :email, :password, :password_confirmation
end
According to the manu
我正在使用CanCan來授權我的資源的Rails項目。當用戶未登錄並嘗試提交「talk」(通過ajax表單提交)時,CanCan會以{"status":"error","message":"You must be logged in to do that!"}作爲響應(我已在瀏覽器中使用螢火蟲驗證過)正確提出401。然而,在我的測試中獲得了一個302響應代碼,而不是401: class Talks
我對rspec非常陌生,我試圖編寫一個測試來確保實際創建的對象確實存在。下面是我的測試是什麼樣子現在: 1) UserService.new should create a UserService object
Failure/Error: service = UserService.new
Errno::ECONNREFUSED:
Connection refus
我正在做邁克爾哈特的Rails教程screencast +第10章的在線書,而且我被困在最後一章銷燬用戶。 控制檯輸出: Failures:
1) UsersController DELETE 'destroy' as an admin user should destroy the user
Failure/Error: delete :destroy, :id =>