【发布时间】:2011-07-31 18:23:47
【问题描述】:
如果有 1 个测试失败,那么还有很多其他测试失败。 我怎么能改变它,以便只有当 be_valid 为真时才能完成下面的其他检查(“it's”),即如何嵌套以下“it's”。我可以为所有其他上下文创建一个不同的上下文,并拥有自己的 be_valid 但我如何确保它们是依赖的(在这种情况下以一种很好的方式!例如它们不会运行)。
describe Gorilla do
context "is valid" do
subject { Factory.build(:gorilla) }
it { should be_valid }
it { should have_many :gorilla_memberships}
it { should have_many(:gorilla_groups).through(:gorilla_memberships) }
it { should have_many :gorilla_observations }
it { should have_one(:avatar).through(:gorilla_observations) }
it { should have_one(:noseprint).through(:gorilla_observations) }
...
【问题讨论】:
标签: ruby-on-rails testing rspec models shoulda