I’m writing tests for my rails app and I’ve found out that as almost an the tests are run on the set of some n variables, I can write them as follows:
[var1, var2, …].each do
describe … do
.
.
end
it … do
.
.
end
end
and so on. But I can’t find a way how to put all that array into a variable, so I can just use variables.each do ….
I’ve tried before(:each), before(:all) and just a declaration of and instance variable (one that starts with @-sign) in a describe group, but all my tries were useless.
Declare
variablesin theRspec.configureblock:And use it inside your specs like this:
You can also declare
variablesoutside of the RSpec configuration block like in the example below, but since you probably already have this block, better keep things clean.