我打算通過軌道教程和上午在section 6.11railstutorial.org - 6.11 - rspec失敗,是postgresql的問題?
出於某種原因,我得到4個實施例和4級中的故障rspec的對4組的實施例和1個發生故障(且因此0)如在教程。
我看到這在我的RSpec:
Failure/Error: @user = User.new(name: "Example User", email: "[email protected]")
ActiveRecord::StatementInvalid:
PGError: ERROR: relation "users" does not exist
的事情是,該教程是在sqlite的合作,而且我遷移到Postgres的(如在前面的教程中建議的),所以我可以瞭解的Postgres以及。這是什麼導致了問題?不應該主動記錄使它對我使用什麼樣的數據庫透明?
我已經創建了適當的數據庫,更新了我的database.yml,運行分貝:mgirate和命令
User.new(name: "Example User", email: "[email protected]")
在沙盒控制檯工作正常。
任何幫助非常感謝。我試圖在這裏保持rspec的頂部,對我來說,這是關於學習Rails的最具挑戰性的部分。它幾乎感覺自己花費了90%的能量編寫和調試測試。 (唯一的絆腳石/心抗彎headca我遇到到目前爲止已經RSpec的測試)
的user_rspec.rb:
require 'spec_helper'
describe User do
before do
@user = User.new(name: "Example User", email: "[email protected]")
end
subject { @user }
it { should respond_to(:name) }
it { should respond_to(:email) }
it { should be_valid }
describe "when name is not present" do
before { @user.name = " " }
it { should_not be_valid }
end
end
-
作爲第二個問題,我發現,我的rspec測試運行多次?我安裝了ruby-gntp gem,並且每次運行測試時都會發現多次彈出咆哮,並帶有相同的信息。