簡體   English   中英

為什么這些rspec測試“未決”?

[英]Why are these rspec tests “pending”?

我正在創建一個Rails應用程序,只是添加了一個文件( app / spec / models / test_spec.rb )和5個新的rspec測試:

describe Topic do
   describe "scopes" do

     before do 
       @public_topic = Topic.create # default is public
       @private_topic = Topic.create(public: false)
     end

     describe "publicly_viewable" do
       it "returns a relation of all public topics" do
         expect(Topic.publicly_viewable).to eq( [@public_topic] )
       end
     end

     describe "privately_viewable" do
       it "returns a relation of all private topics" do
         expect(Topic.privately_viewable).to eq( [@private_topic] )
       end
     end

     describe "visible_to(user)" do
       it "returns all topics if the user is present" do
         user = User.new
         expect(Topic.visible_to(user)).to eq(Topic.all)
       end

       it "returns only public topics if user is nil" do
         expect(Topic.visible_to(nil)).to eq(Topic.publicly_viewable)
       end
     end
  end
end

當我在控制台中運行“ rspec spec”時,得到以下輸出:

完成8.38秒(加載文件需要1分鍾40.84秒)18個示例,1個故障,5個待處理

為什么這五個示例“待定”?

Rspec在spec/其他子目錄中自動為您創建規格。 您正在整個spec/目錄上運行規范,其中包括自動生成的控制器規范,視圖規范,路由規范等。這些帶有待定示例。 如果只想運行此文件中的規范,請運行rspec spec/models/test_spec.rb

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM