Home Rspec: Save record after previous tests
Reply: 0

Rspec: Save record after previous tests

user778 Published in May 23, 2018, 6:38 pm

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
   expect { data.reload }
     .to change { data.status }
         .to(STATUSES[index + 1])

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.326076 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO