Sha256: 6f944f360b5250aa02790a624492040ee4154a63b9d7359c11e4bf110138385d

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

require 'spec_helper'

describe 'description' do
  let(:git) { Git.open(@wdir) }

  before do
    stub_request(:get, 'https://wakatime.com/api/v1/heartbeats')
    .with(query: hash_including(:start, :end))
    .to_return(body: File.read('./spec/fixtures/heartbeats.json'), status: 200)
  end

  it 'can be run on dummy' do
    GitWakaTime.config.git = git
    GitWakaTime::Mapper.new(start_at: Date.new(2015, 1, 24))
    heartbeats = GitWakaTime::Query.new(
      GitWakaTime::Commit, GitWakaTime::CommitedFile, File.basename(@wdir)
    ).get
    timer = GitWakaTime::Timer.new(
      GitWakaTime::Commit.all, heartbeats, File.basename(@wdir)
    ).process

    # # UTC breaks heartbeats of 1 day
    # expect(timer.size).to eq 1
    # With 7 relevant commits
    expect(timer[timer.keys.first].size).to eq 7
    expect(
      timer[Date.new(2015, 1, 30)].map(&:time_in_seconds).compact.reduce(&:+)
    ).to eql(201)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitwakatime-0.2.2 spec/timer_spec.rb
gitwakatime-0.2.1 spec/timer_spec.rb
gitwakatime-0.2.0 spec/timer_spec.rb