Rspecs its
函数已被抽象为separate gem。
这仅仅是为了帮助rspec的开发人员保持井井有条吗?或者its
被认为是代码味?
describe '#initialize' do
subject{ location = Location.new(longitude: 123423, latitude: 444421) }
its(:longitude).should eq 123423
its(:latitude).should eq 444421
end
如果its
是一种气味,我该怎么写上面的?
答案 0 :(得分:0)
开发者在Rspec 3中删除了its
因为根据他们its
经常leads to documentation output that is essentially lies
考虑这样的事情(一般例子,你必须适应你的特定需求):
describe '#conditions_apply_to?' do
let(:product){ Fabricate :product }
it 'returns false when combining with other conditions' do
subject.conditions_combination_operator = 'and'
expect(subject.conditions_apply_to?(product)).to be_false
end
end