Sorry, I don’t know how to word the title better, but here is a general idea of my test:
describe Model do
let(:model) { FactoryGirl.create(:model) }
subject { model }
it { should be_valid }
model.array_attribute.each do |attribute|
context "description" do
specify { attribute.should == 1 }
end
end
end
The problem is that at the line model.array_attribute.each do |attribute|, I get an error of undefined local variable or method model. I know that the let(:model) is working because the validation (among other things) works fine. I suspect that the issue is because it’s being called outside of any actual test (ie. specify, it, etc.).
Any ideas on how to get this to work?
modelis unknown here because it’s only evaluated inside the specs block context.Do something like:
BTW, there is a nice read here.