[英]Why are these rspec tests “pending”?
I'm creating a Rails app and just added a file ( app/spec/models/test_spec.rb )with 5 new rspec tests: 我正在创建一个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
When I ran "rspec spec" in the console, I got the following output: 当我在控制台中运行“ rspec spec”时,得到以下输出:
Finished in 8.38 seconds (files took 1 minute 40.84 seconds to load) 18 examples, 1 failure, 5 pending 完成8.38秒(加载文件需要1分钟40.84秒)18个示例,1个故障,5个待处理
Why are these 5 examples "pending"? 为什么这五个示例“待定”?
Rspec automatically creates specs for you in other sub-directories of spec/
. Rspec在spec/
其他子目录中自动为您创建规格。 You are running the spec on the whole spec/
directory, which includes the auto-generated controller specs, view specs, route specs, etc. These come with pending examples. 您正在整个spec/
目录上运行规范,其中包括自动生成的控制器规范,视图规范,路由规范等。这些带有待定示例。 If you only want to run the specs in this file, run rspec spec/models/test_spec.rb
如果只想运行此文件中的规范,请运行rspec spec/models/test_spec.rb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.