So, in my evolving rspecs for my RoR model, I ended up with two tests in exactly the same way:
it 'is valid when x is zero' do
foo = build(:foo, x: 0, y: 10)
expect(foo.valid?).to be_truthy
end
it 'is valid when y is ten' do
foo = build(:foo, x: 0, y: 10)
expect(foo.valid?).to be_truthy
end
This happened because I wrote a specification to check x first, and then added spec for y after.
Obviously, time for refactoring. I could remove one of the specs because they are duplicates: keep it DRY.
Now the insides of each spec may be exactly the same, but the descriptions itare different. I do not want to lose the information contained there.
My questions are: is it acceptable in this case to preserve the unique specifications of duplicates, or should I "combine" them and change the description it? Maybe:
it 'is valid when x is zero and y is ten' do
foo = build(:foo, x: 0, y: 10)
expect(foo.valid?).to be_truthy
end
, , , ( Foo). . .
, ?