How do you declare a variable that can persist on different tests? For example I have the following
setup do
@payload = {...}
@another_payload = {...}
end
on one controller, I end up copying them to a different controller if I need to use them, is there a way to make them persist across tests?
You could use Concern to do this:
# test/supports/payload_setup.rb
module PayloadSetup
extend ActiveSupport::Concern
included do
setup do
@payload = {...}
@another_payload = {...}
end
end
end
# some_test.rb
class SomeTest < ActiveSupport::TestCase
include PayloadSetup
test 'some test' do
...
end
end