et 0.5.9 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/.github/workflows/ruby.yml +30 -0
 - data/.rubocop.yml +1 -0
 - data/.rubocop_todo.yml +456 -0
 - data/.ruby-version +1 -1
 - data/Gemfile.lock +27 -23
 - data/README.md +17 -0
 - data/et.gemspec +3 -2
 - data/lib/et.rb +1 -2
 - data/lib/et/api.rb +40 -60
 - data/lib/et/fallback_connection.rb +29 -0
 - data/lib/et/lesson.rb +12 -20
 - data/lib/et/runner.rb +2 -16
 - data/lib/et/submission_file_list.rb +58 -0
 - data/lib/et/version.rb +1 -1
 - data/spec/cli/get_lesson_spec.rb +14 -14
 - data/spec/cli/list_lessons_spec.rb +1 -1
 - data/spec/data/.et +1 -0
 - data/spec/data/bloated-challenge/.etignore +4 -0
 - data/spec/data/bloated-challenge/bloated-challenge.md +3 -0
 - data/spec/data/bloated-challenge/node_modules/boo/somefile.js +1 -0
 - data/spec/data/bloated-challenge/problem.rb +1 -0
 - data/spec/data/bloated-challenge/rando_folder/rando_file.js +1 -0
 - data/spec/data/sample-challenge/.etignore +1 -0
 - data/spec/data/sample-exercise/.etignore +1 -0
 - data/spec/lib/api_spec.rb +54 -88
 - data/spec/lib/fallback_connection_spec.rb +42 -0
 - data/spec/lib/lesson_spec.rb +1 -1
 - data/spec/lib/submission_file_list_spec.rb +31 -0
 - data/spec/spec_helper.rb +0 -5
 - metadata +56 -21
 - data/lib/et/challenge.rb +0 -7
 - data/lib/et/exercise.rb +0 -15
 - data/spec/cli/run_exercise_test_suite_spec.rb +0 -31
 - data/spec/data/sample-challenge/.lesson.yml +0 -6
 - data/spec/data/sample-exercise/.lesson.yml +0 -6
 - data/spec/lib/challenge_spec.rb +0 -78
 - data/spec/lib/exercise_spec.rb +0 -28
 
    
        data/lib/et/challenge.rb
    DELETED
    
    
    
        data/lib/et/exercise.rb
    DELETED
    
    | 
         @@ -1,15 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module ET
         
     | 
| 
       2 
     | 
    
         
            -
              class Exercise < Lesson
         
     | 
| 
       3 
     | 
    
         
            -
                def run_tests
         
     | 
| 
       4 
     | 
    
         
            -
                  system("rspec", "--color", "--fail-fast", spec_file)
         
     | 
| 
       5 
     | 
    
         
            -
                end
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                def exists?
         
     | 
| 
       8 
     | 
    
         
            -
                  !dir.nil? && config["type"] == "exercise"
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def spec_file
         
     | 
| 
       12 
     | 
    
         
            -
                  File.join(dir, "test", "#{slug.gsub("-", "_")}_test.rb")
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,31 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            describe "run exercise test suite" do
         
     | 
| 
       2 
     | 
    
         
            -
              context "when in an exercise directory" do
         
     | 
| 
       3 
     | 
    
         
            -
                it "runs the test suite" do
         
     | 
| 
       4 
     | 
    
         
            -
                  Dir.mktmpdir("test") do |tmpdir|
         
     | 
| 
       5 
     | 
    
         
            -
                    write_sample_config_to(tmpdir)
         
     | 
| 
       6 
     | 
    
         
            -
                    exercise_dir = add_sample_exercise(tmpdir)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                    expect_any_instance_of(ET::Exercise).to receive(:run_tests).and_return(true)
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                    runner = ET::Runner.new(exercise_dir)
         
     | 
| 
       11 
     | 
    
         
            -
                    _, _ = capture_output do
         
     | 
| 
       12 
     | 
    
         
            -
                      expect(runner.go(["test"])).to eq(0)
         
     | 
| 
       13 
     | 
    
         
            -
                    end
         
     | 
| 
       14 
     | 
    
         
            -
                  end
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              context "when not in an exercise directory" do
         
     | 
| 
       19 
     | 
    
         
            -
                it "fails to run the test suite" do
         
     | 
| 
       20 
     | 
    
         
            -
                  Dir.mktmpdir("test") do |tmpdir|
         
     | 
| 
       21 
     | 
    
         
            -
                    write_sample_config_to(tmpdir)
         
     | 
| 
       22 
     | 
    
         
            -
                    expect_any_instance_of(ET::Exercise).to_not receive(:run_tests)
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                    runner = ET::Runner.new(tmpdir)
         
     | 
| 
       25 
     | 
    
         
            -
                    _, _ = capture_output do
         
     | 
| 
       26 
     | 
    
         
            -
                      expect(runner.go(["test"])).to eq(1)
         
     | 
| 
       27 
     | 
    
         
            -
                    end
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/lib/challenge_spec.rb
    DELETED
    
    | 
         @@ -1,78 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "yaml"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe ET::Challenge do
         
     | 
| 
       4 
     | 
    
         
            -
              describe "#dir" do
         
     | 
| 
       5 
     | 
    
         
            -
                it "selects the directory containing the challenge file" do
         
     | 
| 
       6 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       7 
     | 
    
         
            -
                    challenge_dir = add_sample_challenge(tmpdir)
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                    challenge = ET::Challenge.new(challenge_dir)
         
     | 
| 
       10 
     | 
    
         
            -
                    expect(challenge.dir).to eq(challenge_dir)
         
     | 
| 
       11 
     | 
    
         
            -
                  end
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                it "checks parent directories for the challenge file" do
         
     | 
| 
       15 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       16 
     | 
    
         
            -
                    challenge_dir = add_sample_challenge(tmpdir)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    child_dir = File.join(challenge_dir, "child")
         
     | 
| 
       19 
     | 
    
         
            -
                    Dir.mkdir(child_dir)
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                    challenge = ET::Challenge.new(child_dir)
         
     | 
| 
       22 
     | 
    
         
            -
                    expect(challenge.dir).to eq(challenge_dir)
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                it "returns nil if no challenge file found" do
         
     | 
| 
       27 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       28 
     | 
    
         
            -
                    challenge = ET::Challenge.new(tmpdir)
         
     | 
| 
       29 
     | 
    
         
            -
                    expect(challenge.dir).to eq(nil)
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              describe "#archive" do
         
     | 
| 
       35 
     | 
    
         
            -
                it "packages up files in the given directory" do
         
     | 
| 
       36 
     | 
    
         
            -
                  archive_path = nil
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  begin
         
     | 
| 
       39 
     | 
    
         
            -
                    Dir.mktmpdir do |tmpdir|
         
     | 
| 
       40 
     | 
    
         
            -
                      challenge_dir = add_sample_challenge(tmpdir)
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                      challenge = ET::Challenge.new(challenge_dir)
         
     | 
| 
       43 
     | 
    
         
            -
                      archive_path = challenge.archive!
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                      contents = read_file_from_gzipped_archive(archive_path, "./problem.rb")
         
     | 
| 
       46 
     | 
    
         
            -
                      expect(contents).to eq("# YOUR CODE GOES HERE\n")
         
     | 
| 
       47 
     | 
    
         
            -
                    end
         
     | 
| 
       48 
     | 
    
         
            -
                  ensure
         
     | 
| 
       49 
     | 
    
         
            -
                    if archive_path && File.exist?(archive_path)
         
     | 
| 
       50 
     | 
    
         
            -
                      FileUtils.rm(archive_path)
         
     | 
| 
       51 
     | 
    
         
            -
                    end
         
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
       53 
     | 
    
         
            -
                end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                it "excludes files in the ignore array" do
         
     | 
| 
       56 
     | 
    
         
            -
                  archive_path = nil
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                  begin
         
     | 
| 
       59 
     | 
    
         
            -
                    Dir.mktmpdir do |tmpdir|
         
     | 
| 
       60 
     | 
    
         
            -
                      challenge_dir = add_sample_challenge(tmpdir)
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                      challenge = ET::Challenge.new(challenge_dir)
         
     | 
| 
       63 
     | 
    
         
            -
                      archive_path = challenge.archive!
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                      files = list_files_in_gzipped_archive(archive_path)
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                      expect(files).to include("./problem.rb")
         
     | 
| 
       68 
     | 
    
         
            -
                      expect(files).to_not include("./sample-challenge.md")
         
     | 
| 
       69 
     | 
    
         
            -
                      expect(files).to_not include("./.lesson.yml")
         
     | 
| 
       70 
     | 
    
         
            -
                    end
         
     | 
| 
       71 
     | 
    
         
            -
                  ensure
         
     | 
| 
       72 
     | 
    
         
            -
                    if archive_path && File.exist?(archive_path)
         
     | 
| 
       73 
     | 
    
         
            -
                      FileUtils.rm(archive_path)
         
     | 
| 
       74 
     | 
    
         
            -
                    end
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/lib/exercise_spec.rb
    DELETED
    
    | 
         @@ -1,28 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            describe ET::Exercise do
         
     | 
| 
       2 
     | 
    
         
            -
              describe "#exists?" do
         
     | 
| 
       3 
     | 
    
         
            -
                it "is true if within an exercise directory" do
         
     | 
| 
       4 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       5 
     | 
    
         
            -
                    exercise_dir = add_sample_exercise(tmpdir)
         
     | 
| 
       6 
     | 
    
         
            -
                    exercise = ET::Exercise.new(exercise_dir)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                    expect(exercise.exists?).to eq(true)
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
                end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                it "is false when in a challenge directory" do
         
     | 
| 
       13 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       14 
     | 
    
         
            -
                    challenge_dir = add_sample_challenge(tmpdir)
         
     | 
| 
       15 
     | 
    
         
            -
                    exercise = ET::Exercise.new(challenge_dir)
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                    expect(exercise.exists?).to eq(false)
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                it "is false when not in a lesson dir" do
         
     | 
| 
       22 
     | 
    
         
            -
                  Dir.mktmpdir do |tmpdir|
         
     | 
| 
       23 
     | 
    
         
            -
                    exercise = ET::Exercise.new(tmpdir)
         
     | 
| 
       24 
     | 
    
         
            -
                    expect(exercise.exists?).to eq(false)
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     |