Reduce code size with array and loop for rspec test

@acmetech @dominicgoulet I want to know if it's a good idea to use loop with array in spec test to minimise the number of code line. I send you this request as an example.