RSpec 中的 it 块和指定块有什么区别?
subject { MovieList.add_new(10) }
specify { subject.should have(10).items }
it { subject.track_number.should == 10}
他们似乎做同样的工作。只是检查确定。
方法是the same;提供它们是为了根据您的测试主体使规范以英语阅读更好。考虑这两个:
describe Array do
describe "with 3 items" do
before { @arr = [1, 2, 3] }
specify { @arr.should_not be_empty }
specify { @arr.count.should eq(3) }
end
end
describe Array do
describe "with 3 items" do
subject { [1, 2, 3] }
it { should_not be_empty }
its(:count) { should eq(3) }
end
end
不定期副业成功案例分享
it
和specify
是相同的方法。您可以查看它们的定义位置 here in the source。should
,而支持expect