<commit_before>RSpec.feature 'Virtual boxes', js: true do
  def wait_for_download
    expect(page).not_to have_content 'Download'
  end

  scenario 'Create new box redirects to download page' do
    visit '/'
    fill_in 'Name', with: 'myapp'
    click_on I18n.t('boxes.form.create')
  
    expect(page).to have_selector(:link_or_button, I18n.t('boxes.show.download'))
  end

  scenario 'Download box' do
    visit '/'
    click_on I18n.t('boxes.form.create')
    click_on I18n.t('boxes.show.download')

    wait_for_download

    files = zip_list_of_files(page.body)
    expect(files).to include('railsbox/development/Vagrantfile',
                             'railsbox/ansible/group_vars/all/config.yml',
                             'railsbox/ansible/roles/postgresql/tasks/main.yml')<commit_msg>Fix intermittently failing test case<commit_after>RSpec.feature 'Virtual boxes', js: true do
  def wait_for_download
    # workaround for https://github.com/thoughtbot/capybara-webkit/issues/319
    page.document.synchronize(2) do
      raise Capybara::ElementNotFound unless page.response_headers['Content-Type'] =~ /zip/
    end
  end

  scenario 'Create new box redirects to download page' do
    visit '/'
    fill_in 'Name', with: 'myapp'
    click_on I18n.t('boxes.form.create')
  
    expect(page).to have_selector(:link_or_button, I18n.t('boxes.show.download'))
  end

  scenario 'Download box' do
    visit '/'
    click_on I18n.t('boxes.form.create')
    click_on I18n.t('boxes.show.download')

    wait_for_download

    files = zip_list_of_files(page.body)
    expect(files).to include('railsbox/development/Vagrantfile',
                             'railsbox/ansible/group_vars/all/config.yml',
                             'railsbox/ansible/roles/postgresql/tasks/main.yml')
{'fraction_non_alphanumeric': 0.11682504192286193, 'fraction_numerical': 0.011179429849077696, 'mean_word_length': 3.0315315315315314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3205554', 'n_tokens_mistral': 613, 'n_tokens_neox': 582, 'n_words': 107}