0
4

1 回答 1

1

Declare variables in the Rspec.configure block:

RSpec.configure do |config|
  config.add_setting :variables, :default =>  [1, 2]
end

And use it inside your specs like this:

RSpec.configuration.variables.each do |i|
end

You can also declare variables outside of the RSpec configuration block like in the example below, but since you probably already have this block, better keep things clean.

RSpec.configuration.add_setting :variables, :default =>  [1, 2]
于 2012-05-31T22:51:39.920 回答