I want to run tests dynamically, using the loop. What I have:
let!(:product) { create(:product) }
let!(:data) { product.some_data_object }
let(:run_action) { patch :next_status, params: { id: data.id } }
STATUSES.each_with_index do |status, index|
it "changes status from #{status} to #{STATUSES[index + 1]}" do
run_action
expect { data.reload }
.to change { data.status }
.from(status)
.to(STATUSES[index + 1])
end
end
end
Each test should check if data.status is changed by one step from the array. But before each test data.status has the first value from the array.
So how can I get the old record with all changes after the previous test? Thank you.
Aucun commentaire:
Enregistrer un commentaire