Betterspecs建议使用类似的东西:
subject { assigns('message') }
it { should match /it was born in Billville/ }
作为良好的做法。但如果我想以 doc 格式 ( rspec -f doc
) 运行 rspec,我会收到:
When you call a matcher in an example without a String, like this:
specify { object.should matcher }
or this:
it { should matcher }
RSpec expects the matcher to have a #description method. You should either
add a String to the example this matcher is being used in, or give it a
description method. Then you won't have to suffer this lengthy warning again.
所以这
it "some desc" do
should match /it was born in Billville/
end
不会提出那个烦人的信息,但看起来很丑。
关于如何保持 rspec 约定和代码干净的任何想法,并且仍然有一些漂亮的输出(比如 with -f doc
)?
rspec v.2.13.0