Sha256: 255d24474991772dccd04a7d181aaf394ce599384106826cd124ea25ca2d56c1

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe LearnOpen::LessonDownloader do
  let(:lesson)   { double }
  let(:location) { double }
  let(:environment) { double }
  let(:downloader) { LearnOpen::LessonDownloader.new(lesson, location, environment) }

  context 'downloaded lesson' do
    before do
      allow(downloader).to receive(:repo_exists?).and_return(true)
    end

    context 'able to make an SSH connection' do
      before do
        allow(downloader).to receive(:ensure_git_ssh!).and_return(true)
        allow(downloader).to receive(:fork_repo)
        allow(downloader).to receive(:clone_repo)
      end

      it 'returns status :noop' do
        expect(downloader.call).to eq :noop
      end
    end
  end

  context 'undownloaded lesson' do
    before do
      allow(downloader).to receive(:repo_exists?).and_return(false)
    end

    context 'able to make an SSH connection' do
      before do
        allow(downloader).to receive(:ensure_git_ssh!).and_return(true)
        allow(downloader).to receive(:fork_repo)
        allow(downloader).to receive(:clone_repo)
      end

      it 'forks the repo' do
        expect(downloader).to receive(:fork_repo)
        downloader.call
      end

      it 'clones the repo' do
        expect(downloader).to receive(:clone_repo)
        downloader.call
      end
    end

    context 'unable to make an SSH connection' do
      before do
        allow(downloader).to receive(:ensure_git_ssh!).and_return(false)
      end

      it 'returns status :ssh_unauthenticated' do
        expect(downloader.call).to eq :ssh_unauthenticated
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
learn-open-1.2.22 spec/learn_open/services/lesson_downloader_spec.rb