Skip to content

Commit

Permalink
test: use mocks for set up an available and unavailable subject
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagorodriguez96 committed Jun 17, 2024
1 parent 621acc4 commit 53fce2f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions spec/models/activity_prerequisite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
context 'when the approvable needed is available' do
it 'returns true' do
subject_needed = create :subject, :with_exam
create :credits_prerequisite, approvable: subject_needed.exam, credits_needed: 5

allow(subject_needed.exam).to receive(:available?).and_return(true)
prerequisite = create :activity_prerequisite, approvable_needed: subject_needed.exam

expect(prerequisite.met?([create(:subject, credits: 5).course])).to be_truthy
expect(prerequisite.met?([])).to be_truthy
end
end

context 'when the approvable needed is not available' do
it 'returns false' do
subject_needed = create :subject, :with_exam
create :credits_prerequisite, approvable: subject_needed.exam, credits_needed: 5

allow(subject_needed.exam).to receive(:available?).and_return(false)
prerequisite = create :activity_prerequisite, approvable_needed: subject_needed.exam

expect(prerequisite.met?([])).to be_falsey
Expand Down

0 comments on commit 53fce2f

Please sign in to comment.