ruby on rails 4 - Run through Rspec test multiple times based on argument from array -



ruby on rails 4 - Run through Rspec test multiple times based on argument from array -

i'm implementing stripe , doing integration tests. stripe provides multiple cc numbers, , want iterate through each of these. like:

@stripe_success_cards = [ "4242424242424242", #visa "4012888888881881", #visa "4000056655665556", #visa debit "5555555555554444", #mc "5200828282828210", #mc debit "378282246310005", #amex "371449635398431", #amex "6011111111111117", #discover "6011000990139424", #discover "30569309025904", #diner's club "38520000023237", #diner's club "3530111333300000", #jcb "3566002020360505" #jcb ] @stripe_success_cards.each |card_number| describe "user fills out stripe information" before page.execute_script(%q{ $('input#card_number').val('#{card_number}'); }) end "should trigger charge" ... end end end

but above doesn't work because of limitations on variables in rspec integration testing. how can this? trying maintain test dry, because each form has lot fill out , there lot of examples go through.

thanks!

this work if utilize local variable instead of instance variable:

stripe_success_cards = [ "4242424242424242", #visa "4012888888881881", #visa "4000056655665556", #visa debit "5555555555554444", #mc "5200828282828210", #mc debit "378282246310005", #amex "371449635398431", #amex "6011111111111117", #discover "6011000990139424", #discover "30569309025904", #diner's club "38520000023237", #diner's club "3530111333300000", #jcb "3566002020360505" #jcb ] stripe_success_cards.each |card_number| describe "user fills out stripe information" before page.execute_script(%q{ $('input#card_number').val('#{card_number}'); }) end "should trigger charge" ... end end end

ruby-on-rails-4 rspec integration-testing dry stripe-payments

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -