Sha256: b11b959e849ee9763c663ea9df29bc191e06ca9e318a654e483898fbb796bee1

Contents?: true

Size: 837 Bytes

Versions: 5

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper_models'

describe Gaku::ExternalSchoolRecord do

  describe 'associations' do
    it { should belong_to :school }
    it { should belong_to :student }
  end

  describe 'validations' do
    it { should validate_presence_of :student }
    it { should validate_presence_of :school }
  end

  describe '#attendance_rate' do
    let(:external_school_record) do
      build(:external_school_record, total_units: 16, units_absent: 13)
    end

    let(:external_school_record2) { build(:external_school_record) }

    it 'return attendance rate if total_units and units_absent are present' do
      expect(external_school_record.attendance_rate).to eq 18.75
    end

    it 'return nil if total_units and units_absent are not present' do
      expect(external_school_record2.attendance_rate).to eq nil
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gaku-0.2.4 core/spec/models/external_school_record_spec.rb
gaku-0.2.3 core/spec/models/external_school_record_spec.rb
gaku-0.2.2 core/spec/models/external_school_record_spec.rb
gaku-0.2.1 core/spec/models/external_school_record_spec.rb
gaku-0.2.0 core/spec/models/external_school_record_spec.rb