我正在创建一个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个未决
为什么这5个例子“待定”?
答案 0 :(得分:1)
Rspec会在spec/
的其他子目录中自动为您创建规范。您正在整个spec/
目录中运行规范,其中包括自动生成的控制器规范,视图规范,路由规范等。这些都带有待处理的示例。如果您只想运行此文件中的规范,请运行rspec spec/models/test_spec.rb