Give the below simple example :
let(:item) { create(:item }
it 'query by scope' do
expect(Item.all.length).to eq 1
end
The test does not pass.
Adding item.save within the it block, the test pass. Using a before(:each) { create(:item) } instead of let make the test pass too.
Sounds obvious, as the point I might be missing, why is let not effectively creating the record in this case ?
Aucun commentaire:
Enregistrer un commentaire