<commit_before>require 'rails_helper'

describe Study do
  it "should have expected date values" do
    xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
    study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create
    expect(study.first_received_results_disposition_date).to eq('December 1, 1999'.to_date)
  end
  
  context 'when patient data section exists' do
    it 'should have expected sharing ipd value' do
      xml=Nokogiri::XML(File.read('spec/support/xml_data/NCT02830269.xml'))
      study=Study.new({xml: xml, nct_id: 'NCT02830269'}).create
      expect(study.plan_to_share_ipd).to eq('Undecided')
    end

    it 'should have expected ipd description value' do
      xml=Nokogiri::XML(File.read('spec/support/xml_data/NCT02830269.xml'))
      study=Study.new({xml: xml, nct_id: 'NCT02830269'}).create
      expect(study.plan_to_share_description).to eq('NC')
    end
  end

  context 'when patient data section does not exist' do
    it 'should return empty string for sharing ipd value' do
      xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
      study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create
      expect(study.plan_to_share_ipd).to eq('')
    end

    it 'should return empty string for ipd description value' do
      xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
      study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create
      expect(study.plan_to_share_description).to eq('')
    end
  end
end<commit_msg>Mini refactor of study_content_spec tests<commit_after>require 'rails_helper'

describe Study do
  it "should have expected date values" do
    xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
    study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create
    expect(study.first_received_results_disposition_date).to eq('December 1, 1999'.to_date)
  end

  context 'when patient data section exists' do
    xml=Nokogiri::XML(File.read('spec/support/xml_data/NCT02830269.xml'))
    study=Study.new({xml: xml, nct_id: 'NCT02830269'}).create

    it 'should have expected sharing ipd value' do
      expect(study.plan_to_share_ipd).to eq('Undecided')
    end

    it 'should have expected ipd description value' do
      expect(study.plan_to_share_description).to eq('NC')
    end
  end

  context 'when patient data section does not exist' do
    xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
    study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create

    it 'should return empty string for sharing ipd value' do
      expect(study.plan_to_share_ipd).to eq('')
    end

    it 'should return empty string for ipd description value' do
      expect(study.plan_to_share_description).to eq('')
    end
  end
end
{'fraction_non_alphanumeric': 0.11879049676025918, 'fraction_numerical': 0.035277177825773935, 'mean_word_length': 4.273244781783681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 40}, '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': '5608701', 'n_tokens_mistral': 1044, 'n_tokens_neox': 934, 'n_words': 211}