Sha256: 74c2451e7158fc379f11c89017b5724e3ba24a40ca973709f180358f9eb7fac3

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

RSpec.describe MerchCalendar do
  context "responds to util methods" do
    [
      :start_of_month, :end_of_month,
      :start_of_year, :end_of_year,
      :start_of_quarter, :end_of_quarter,
      :merch_to_julian,
      :julian_to_merch,
      :weeks_in_year,
      :weeks_for_month
    ].each do |method_name|
      it "responds to the #{method_name} method" do
        expect(described_class).to respond_to(method_name)
      end
    end
  end

  describe "#start_of_week" do
    it "returns the correct date for a given merch week" do
      expect(described_class.start_of_week(2017, 4, 1)).to eq Date.new(2017, 4, 2)
    end
  end

  describe "#end_of_week" do
    it "returns the correct date for a given merch week" do
      expect(described_class.end_of_week(2017, 4, 1)).to eq Date.new(2017, 4, 8)
    end
  end

  it "#start_of_month" do
    expect(described_class.start_of_month(2014,1)).to be_a Date
  end

  it "#end_of_month" do
    expect(described_class.end_of_month(2014,1)).to be_a Date
  end

  it "#start_of_year" do
    expect(described_class.start_of_year(2014)).to be_a Date
  end

  it "#end_of_year" do
    expect(described_class.end_of_year(2014)).to be_a Date
  end

  it "#start_of_quarter" do
    expect(described_class.start_of_quarter(2014,1)).to be_a Date
  end

  it "#end_of_quarter" do
    expect(described_class.end_of_quarter(2014,1)).to be_a Date
  end

  it "#weeks_in_year" do
    expect(described_class.weeks_in_year(2014)).to be_a Fixnum
  end

  it "#merch_to_julian" do
    expect(described_class.merch_to_julian(1)).to be_a Fixnum
  end

  it "#julian_to_merch" do
    expect(described_class.julian_to_merch(1)).to be_a Fixnum
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
merch_calendar-0.0.5 spec/merch_calendar_spec.rb
merch_calendar-0.0.5.rc1 spec/merch_calendar_spec.rb