<commit_before>require "spec_helper"
require 'yaml'

RSpec.describe "work", :js => true, :type => :feature do
  before do
    visit "/#/work"
  end

  let :work_data do
    work_file = get_data_file("work.yml")
    YAML.load_file(work_file)
  end
  
  it "renders work template" do
    expect(page).to have_selector ".page-container .work-page" 
  end

  it "displays each job in data/work.yml" do
    jobs = page.all ".work-container"
    data_job_count = work_data["descriptions"].length
    expect(jobs.count).to be(data_job_count)

    work_data["descriptions"].each do |job|

    end
  end
end<commit_msg>Add test to ensure data/work.yml properties are embedded in work page<commit_after>require "spec_helper"
require 'yaml'

RSpec.describe "work", :js => true, :type => :feature do
  before do
    visit "/#/work"
  end

  let :work_data do
    work_file = get_data_file("work.yml")
    YAML.load_file(work_file)
  end
  
  it "renders work template" do
    expect(page).to have_selector ".page-container .work-page" 
  end

  it "displays job properties from data/work.yml" do
   text_properties = [
      "name",
      "position",
      "start_date",
      "end_date",
      "location",
      "text"
    ]
    image_properties = [
      "image"
    ]
    html_properties = [
      "extras"
    ]

    jobs = page.all ".work-container"
    data_job_count = work_data["descriptions"].length
    expect(jobs.count).to be(data_job_count)

    work_data["descriptions"].each_with_index do |data_job, index|
      page_job = jobs[index]

      text_properties.each do |prop|
        expect(data_job).to have_key(prop)
        expect(page_job).to have_text(data_job[prop])
      end

      image_properties.each do |prop|
        expect(data_job).to have_key(prop)
        expect(page_job).to have_selector(
          "img[src='/images/#{data_job[prop]}']"
        )
      end

      html_properties.each do |prop|
        expect(data_job).to have_key(prop)
        # could not find method to get html of page_job
        expect(page.body).to include(data_job[prop])
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11599045346062052, 'fraction_numerical': 0.0, 'mean_word_length': 2.8178506375227688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5739446', 'n_tokens_mistral': 728, 'n_tokens_neox': 701, 'n_words': 163}