<commit_before>require 'rails_helper'
require_relative '../../app/domain/usecases/dates/get_next_day_occur_human_readable'

describe 'UseCases::Dates' do

  before(:all) do
    I18n.locale = :en
    @date_current = Date.parse('19-03-2015')
  end

  describe 'get_next_day_occur_human_readable' do
    context 'when object occur today' do
      it 'should return today' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 4, name: "Thursday", binary: 4, organizer_id: 4),
                       double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Today'
      end
    end

    context 'when object occur tomorrow' do
      it 'should return tomorrow' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Tomorrow'
      end
    end

    context 'when object occur in saturday' do
      it 'should return saturday' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Saturday'
      end
    end

    context 'when object occur in 30 days period' do
      it 'should return 19/Mar' do
        event = build(:event, date_start: @date_current + 10, date_finish: @date_current + 30)
        weeks_array = [double('Week', id: 4, name: "Thursday", binary: 4, organizer_id: 4)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq '19/Mar'
      end
    end

    context 'when object occur in 60 days period' do
      it 'should return 19/May' do
        event = build(:event, date_start: @date_current + 60, date_finish: @date_current + 65)
        weeks_array = [double('Week', id: 4, name: "Thursday", binary: 4, organizer_id: 4)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq '21/May'
      end
    end

  end

end<commit_msg>Adjust in tests for date of week<commit_after>require 'rails_helper'
require_relative '../../app/domain/usecases/dates/get_next_day_occur_human_readable'

describe 'UseCases::Dates' do

  before(:all) do
    I18n.locale = :en
    @date_current = Date.parse('19-03-2015')
  end

  describe 'get_next_day_occur_human_readable' do
    context 'when object occur today' do
      it 'should return today' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 4, name: "Thursday", binary: 4, organizer_id: 4),
                       double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Today'
      end
    end

    context 'when object occur tomorrow' do
      it 'should return tomorrow' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Tomorrow'
      end
    end

    context 'when object occur in saturday' do
      it 'should return saturday' do
        event = build(:event, date_start: @date_current, date_finish: @date_current + 6)
        weeks_array = [double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq 'Saturday'
      end
    end

    context 'when object occur in 30 days period' do
      it 'should return 29/Mar' do
        event = build(:event, date_start: @date_current + 10, date_finish: @date_current + 30)
        weeks_array = [double('Week', id: 4, name: "Thursday", binary: 4, organizer_id: 4),
                       double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq '29/Mar'
      end
    end

    context 'when object occur in 60 days period' do
      it 'should return 18/May' do
        event = build(:event, date_start: @date_current + 60, date_finish: @date_current + 65)
        weeks_array = [double('Week', id: 1, name: "Monday", binary: 1, organizer_id: 1),
                       double('Week', id: 5, name: "Friday", binary: 5, organizer_id: 5),
                       double('Week', id: 6, name: "Saturday", binary: 6, organizer_id: 6),
                       double('Week', id: 7, name: "Sunday", binary: 0, organizer_id: 7)]
        allow(event).to receive(:weeks).and_return(weeks_array)

        result = Villeme::UseCases::Dates.get_next_day_occur_human_readable(event, true)

        expect(result).to eq '18/May'
      end
    end

  end

end
{'fraction_non_alphanumeric': 0.128339222614841, 'fraction_numerical': 0.02120141342756184, 'mean_word_length': 2.907233572611817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3431660', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2168, 'n_words': 603}