et 0.5.9 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +0,0 @@
1
- module ET
2
- class Challenge < Lesson
3
- def exists?
4
- !dir.nil? && config["type"] == "challenge"
5
- end
6
- end
7
- end
@@ -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
@@ -1,6 +0,0 @@
1
- ---
2
- title: "Sample Challenge"
3
- type: "challenge"
4
- description: "Some description."
5
- ignore:
6
- - "sample-challenge.md"
@@ -1,6 +0,0 @@
1
- ---
2
- title: "Sample Exercise"
3
- type: "exercise"
4
- description: "Some description here."
5
- ignore:
6
- - "sample-exercise.md"
@@ -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
@@ -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