Shoulda: How would I use an instance variable outside of a setup or should block?
- by TheDeeno
I'm trying to do something like the following:
@special_attributes = Model.new.methods.select # a special subset
@special_attributes.each do |attribute|
context "A model with #{attribute}"
setup do
@model = Model.new
end
should "have some special characteristic"
assert @model.method(attribute).call
end
end
end
However, @special_attributes is out of scope when running the unit tests, leaving me with a nil object on line 2. I can't figure out where to define it to bring it in scope. Any thoughts?