当我编写RSpec测试时,我经常将describe
块命名为哈希或句点,例如类和方法。
describe "#do_stuff" do
it "does instance stuff" do
thing = Thing.new
thing.do_stuff
expect(thing.stuff_done?).to eq(true)
end
end
describe ".do_more_stuff" do
it "does class stuff" do
Thing.do_more_stuff
expect(thing.more_stuff_done?).to eq(true)
end
end
是否有属性的等价物?我需要测试由于自定义读者而具有特殊行为的属性默认值和属性。