In a Rails (5.2) project I want to parametrize a system test (Capybara) based on different objects from a test fixture. I have:
class SomethingWithUsers < ApplicationSystemTestCase
setup do
@user1 = users(:test_user1)
@user2 = users(:test_user2)
end
test "some_test" do
login @user1
do_stuff
assert other_stuff
end
end
and I have a users.yml fixture.
So now instead of adding second test for @user2, I want to parametrize the some_test
I tried:
[@user1, @user2].each do |user|
test "some_test" + user.name
login user
do_stuff
assert other_stuff
end
end
but user
gets nil. So obviously I don't have access to these vars in this way.
[users(:test_user1), users(:test_user2)].each do |user|
is also not working. So I am out of ideas.
Aucun commentaire:
Enregistrer un commentaire