-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kostik
committed
Dec 4, 2023
1 parent
982b07b
commit 87f2750
Showing
3 changed files
with
428 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,19 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe StudyJsonRecord::ProcessorV2, type: :model do | ||
describe '#brief_summary_data' do | ||
let(:json) { { 'protocolSection' => protocol_section } } | ||
let(:processor_v2) { described_class.new(json) } | ||
|
||
context 'when protocol section is not present' do | ||
let(:protocol_section) { nil } | ||
|
||
it 'returns nil' do | ||
expect(processor_v2.brief_summary_data).to be_nil | ||
end | ||
describe 'brief_summary_data' do | ||
|
||
it 'should test brief_summary_data' do | ||
expected_data = { | ||
nct_id: 'NCT03630471', | ||
description: 'We will conduct a two-arm individually randomized controlled trial in six Government-run secondary schools in New Delhi. The targeted sample is 240 adolescents in grades 9-12 with persistent, elevated mental health difficulties and associated impact. Participants will receive either a brief problem-solving intervention delivered by lay counsellors (intervention), or enhanced usual care comprised of problem-solving booklets (control). Self-reported adolescent mental health difficulties and idiographic problems will be assessed at 6 weeks (co-primary outcomes) and again at 12 weeks post-randomization. In addition, adolescent-reported impact of mental health difficulties, perceived stress, mental wellbeing and clinical remission, as well as parent-reported adolescent mental health difficulties and impact scores, will be assessed at 6 and 12 weeks post-randomization. Parallel process evaluation, including estimations of the costs of delivering the interventions, will be conducted.' | ||
} | ||
hash = JSON.parse(File.read('spec/support/json_data/NCT03630471.json')) | ||
processor = StudyJsonRecord::ProcessorV2.new(hash) | ||
expect(processor.brief_summary_data).to eq(expected_data) | ||
end | ||
|
||
context 'when description module is not present' do | ||
let(:protocol_section) { {} } | ||
|
||
it 'returns nil' do | ||
expect(processor_v2.brief_summary_data).to be_nil | ||
end | ||
end | ||
|
||
context 'when brief summary is present' do | ||
let(:protocol_section) do | ||
{"identificationModule"=> { | ||
"nctId": "NCT03630471" | ||
}, | ||
'descriptionModule' => { | ||
'briefSummary' => 'This is a brief summary.' | ||
} | ||
} | ||
end | ||
|
||
it 'returns the correct data' do | ||
allow(processor_v2).to receive(:nctId).and_return('NCT12345') | ||
|
||
expected_data = { | ||
nct_id: 'NCT12345', | ||
description: 'This is a brief summary.' | ||
} | ||
|
||
expect(processor_v2.brief_summary_data).to eq(expected_data) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.