我创建一个Rails应用程序,只是增加了一个文件(应用/规格/型号/ test_spec.rb )5个新RSpec的测试:为什么这些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的规格”控制台,我得到了以下的输出:
在8.38秒(文件耗时1分40.84秒加载) 18例,1次失败,完成5未决
为什么这些例子5“待处理”?
'rspec spec'命令应该告诉您哪些测试正在等待处理。你确定他们是这些吗? –
另外,为了什么是值得的,我正在处理某个特定的功能,我喜欢只运行该部分的单元测试。因此,而不是'rspec spec',我会使用'rspec'spec/models/test_spec.rb'-fd'。然后,一旦我的单元测试通过,我会做全套装,集成测试等。顺便说一句,'-fd'给你很好的输出格式。 – jvillian
@jvillian - 感谢您的回复。当我运行'rspec'spec/models/test_spec.rb'-fd'时,我得到这个输出:_/home/nitrous/code/bloccit/spec/models/topic_spec.rb:1:在中:未初始化的常量Topic(NameError) from /home/nitrous/code/project/.bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in加载 from/home/nitrous /code/bloccit/.bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in load_spec_files from /home/nitrous/code/bloccit/.bundle/gems/ rspec-core -... _ –