Sha256: 503e36ae92304b30cc52deb7cbd48fb6212efccc023476ce2e3b9784e7be193e

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require_relative '../../test_helper'

describe PrayerTimes::CalculationMethod do
  
  let(:name){"Medina"}
  let(:description){"Medina testing methods"}
  
  describe "Object" do
    subject{PrayerTimes::CalculationMethod.new(name, description,{})}
    it {subject.must_respond_to :description}
    it {subject.must_respond_to :description=}
    it {subject.must_respond_to :settings}
    it {subject.must_respond_to :settings=}
    it {subject.must_respond_to :offsets}
    it {subject.must_respond_to :offsets=}
  end
  
  describe "#initialize" do
    context "when name and description are provided" do
      subject{PrayerTimes::CalculationMethod.new(name, description)}
      it {subject.name.must_equal(name)}
      it {subject.description.must_equal(description)}
    end
    
    context "when settings are not provided" do
      subject{PrayerTimes::CalculationMethod.new(name, description, {})}
      it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings)}
    end
       
    context "when settings are provided" do
      let(:opts){{
         fajr:       18,
         asr:        'Hanafi',
         isha:       18
      }}
      subject{PrayerTimes::CalculationMethod.new(name, description,opts)}
      it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings.merge opts)}
    end   
    
    context "when offsets are not provided" do
      subject{PrayerTimes::CalculationMethod.new(name, description, {}, {})}
      it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets)}
    end
       
    context "when offsets are provided" do
      let(:opts){{
         fajr:       3,
         asr:        -1,
         isha:       6
      }}
      subject{PrayerTimes::CalculationMethod.new(name, description,{},opts)}
      it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets.merge opts)}
    end     
       
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prayer_times-0.1.0 test/lib/prayer_times/calculation_method_test.rb