Sha256: bbcfd4dc22b5ea99d85e7c84a34455dbf77b036185d2e594979dfb800ea10944

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe LearnOpen::LessonDownloader do
  let(:lesson)   { double(use_student_fork: true) }
  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

5 entries across 5 versions & 1 rubygems

Version Path
learn-open-1.2.28 spec/learn_open/services/lesson_downloader_spec.rb
learn-open-1.2.27 spec/learn_open/services/lesson_downloader_spec.rb
learn-open-1.2.26 spec/learn_open/services/lesson_downloader_spec.rb
learn-open-1.2.24 spec/learn_open/services/lesson_downloader_spec.rb
learn-open-1.2.23 spec/learn_open/services/lesson_downloader_spec.rb