Skip to content

Instantly share code, notes, and snippets.

@AlexeyAndrianov
Last active November 27, 2019 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexeyAndrianov/88f1a502c6385ac7d41b100f325b8c90 to your computer and use it in GitHub Desktop.
Save AlexeyAndrianov/88f1a502c6385ac7d41b100f325b8c90 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'Backoffice: Bba Reference', version: [:vl_test], :js => true do
let(:application_page) { Pages::ApplicationPage.new }
let(:invalid_bba_reference) { '123123412345' }
let(:valid_bba_reference) { '010806817183' }
before(:all) do
login_and_create_corporate_account(corporate_iban, portfolio_id: PortfolioFeeder::DEBIT_CARDS_ACTIVATION_PORTFOLIO_ID)
open_account_details_page_by_iban(corporate_iban)
sleep(3)
click_link('Create transfer')
end
context 'When filling bba reference' do
it 'with invalid value' do
fill_in_bba_reference(invalid_bba_reference)
expect(page).to have_content("Invalid bba reference")
##############
# binding.pry
end
it 'with valid value' do
# binding.pry
fill_in_bba_reference(valid_bba_reference)
expect(page).not_to have_content("Invalid bba reference")
end
end
private
def corporate_iban
@corporate_iban ||= generate_iban
end
def fill_in_bba_reference(reference_number)
reset_bba_reference
bba_reference = prepare_values(reference_number)
# bba_reference = reference_number.to_s.scan(/\d/) do
#TODO: refactor code below
# end
fill_bba_reference_fields(bba_reference)
unblur_input
end
def prepare_values(reference_number)
reference_number.to_s
bba_reference = []
bba_reference << reference_number[0..2]
bba_reference << reference_number[3..6]
bba_reference << reference_number[7..11]
bba_reference
end
def reset_bba_reference
fill_bba_reference_fields([])
end
def fill_bba_reference_fields(array_data)
3.times do |index|
fill_in("action_object[resource_attributes][bba_reference(#{index+1}i)]", with: array_data[index] || '')
end
end
def unblur_input
find('body').click
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment