Sha256: 03db4659609028d90bacc9c4eada236fcd9310569ae5ee282452f97c4611275e

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'

class Hexlet::MemberCLITest < MiniTest::Test
  def setup
    @router = Hexlet::Router.new
  end

  def test_login
    api_key = "api_key"
    config_file = File.join(Dir.home, ".hexlet", "credentials")

    stub = stub_request(:get, @router.api_member_user_check_url).
      to_return(:status => 200)

    FakeFS do
      result = Hexlet::MemberCLI.start ["login", api_key, "--verbose"]
      assert { result }
      assert { File.file?(config_file) }
    end

    assert_requested stub
  end

  def test_fetch
    stub = stub_request(:get, @router.api_member_lesson_backend_url("my_super", "exercise")).
      to_return(:status => 200)

    FakeFS do
      result = Hexlet::MemberCLI.start ["fetch", "my_super", "exercise", "--verbose"]
      assert { result }
    end

    assert_requested stub
  end

  def test_submit
    stub = stub_request(:post, @router.api_member_lesson_backend_results_url("my_super", "exercise")).
      to_return(:status => 201)
    Open3.stubs(:capture3).returns(["", "", 0])

    FakeFS do
      folder = "my_super_lesson/exercise"
      FileUtils.mkdir_p(folder)
      result = Hexlet::MemberCLI.start ["submit", folder, "--verbose"]
      assert { result }
    end

    assert_requested stub
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hexlet-0.3.3 test/hexlet/member_cli_test.rb
hexlet-0.3.2 test/hexlet/member_cli_test.rb
hexlet-0.3.1 test/hexlet/member_cli_test.rb
hexlet-0.3.0 test/hexlet/member_cli_test.rb
hexlet-0.2.2 test/hexlet/member_cli_test.rb
hexlet-0.2.1 test/hexlet/member_cli_test.rb
hexlet-0.2.0 test/hexlet/member_cli_test.rb
hexlet-0.1.1 test/hexlet/member_cli_test.rb