I want to check that an array contains only objects of a specific class, let's say Float
.
A working example at the moment:
it "tests array_to_test class of elements" do
expect(array_to_test.count).to eq(2)
expect(array_to_test[0]).to be_a(Float)
expect(array_to_test[1]).to be_a(Float)
end
Is there a way to validate if the array_to_test
contains only Float
instances?
Sample non-working pseudocode:
it "tests array_to_test class of elements" do
expect(array_to_test).to be_a(Array[Float])
end
Do not consider Ruby and Rspec version as a restriction.
Aucun commentaire:
Enregistrer un commentaire