belajar 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -4
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/Gemfile +1 -1
  5. data/README.md +76 -1
  6. data/Rakefile +1 -1
  7. data/belajar.gemspec +23 -26
  8. data/belajar.png +0 -0
  9. data/bin/belajar +6 -2
  10. data/lib/belajar.rb +0 -1
  11. data/lib/belajar/chapter.rb +3 -4
  12. data/lib/belajar/coloring.rb +32 -0
  13. data/lib/belajar/configuration.rb +25 -28
  14. data/lib/belajar/congratulator.rb +17 -5
  15. data/lib/belajar/course.rb +9 -8
  16. data/lib/belajar/exceptions.rb +0 -2
  17. data/lib/belajar/generator.rb +13 -15
  18. data/lib/belajar/github_client.rb +5 -5
  19. data/lib/belajar/loadable.rb +23 -14
  20. data/lib/belajar/loading/chapters.rb +0 -2
  21. data/lib/belajar/loading/courses.rb +0 -2
  22. data/lib/belajar/loading/units.rb +0 -2
  23. data/lib/belajar/markdown.rb +2 -0
  24. data/lib/belajar/markdown/printer.rb +89 -0
  25. data/lib/belajar/markdown/ruby_doc.rb +104 -0
  26. data/lib/belajar/solution.rb +23 -15
  27. data/lib/belajar/storeable.rb +11 -12
  28. data/lib/belajar/task.rb +1 -1
  29. data/lib/belajar/terminal.rb +3 -4
  30. data/lib/belajar/terminal/cli.rb +8 -8
  31. data/lib/belajar/terminal/courses.rb +24 -21
  32. data/lib/belajar/terminal/output.rb +46 -53
  33. data/lib/belajar/terminal/setup.rb +13 -18
  34. data/lib/belajar/terminal/solutions.rb +27 -32
  35. data/lib/belajar/terminal/texts/hint_course_download.txt +2 -2
  36. data/lib/belajar/terminal/welcome.rb +9 -11
  37. data/lib/belajar/test.rb +7 -10
  38. data/lib/belajar/test_result.rb +54 -21
  39. data/lib/belajar/unit.rb +2 -4
  40. data/lib/belajar/version.rb +1 -1
  41. data/lib/belajar/views.rb +29 -33
  42. data/lib/belajar/views/chapters_menu.rb +16 -20
  43. data/lib/belajar/views/courses_menu.rb +12 -15
  44. data/lib/belajar/views/main_menu.rb +23 -23
  45. data/lib/belajar/views/menu.rb +14 -18
  46. data/lib/belajar/views/splash.rb +11 -13
  47. data/lib/belajar/views/subscriber.rb +38 -0
  48. data/lib/belajar/views/task_view.rb +97 -80
  49. data/lib/belajar/views/top_bar.rb +4 -10
  50. data/lib/belajar/views/units_menu.rb +16 -21
  51. data/lib/belajar/window.rb +20 -140
  52. data/spec/belajar/chapter_spec.rb +23 -18
  53. data/spec/belajar/coloring_spec.rb +35 -0
  54. data/spec/belajar/configuration_spec.rb +55 -51
  55. data/spec/belajar/congratulator_spec.rb +11 -8
  56. data/spec/belajar/course_spec.rb +75 -52
  57. data/spec/belajar/generator_spec.rb +24 -25
  58. data/spec/belajar/github_client_spec.rb +17 -18
  59. data/spec/belajar/loading/chapters_spec.rb +2 -3
  60. data/spec/belajar/loading/courses_spec.rb +2 -3
  61. data/spec/belajar/loading/units_spec.rb +4 -5
  62. data/spec/belajar/markdown/ruby_doc_spec.rb +116 -0
  63. data/spec/belajar/reference_solution_spec.rb +8 -10
  64. data/spec/belajar/solution_spec.rb +21 -22
  65. data/spec/belajar/storeable_spec.rb +12 -10
  66. data/spec/belajar/task_spec.rb +3 -4
  67. data/spec/belajar/terminal/cli_spec.rb +29 -21
  68. data/spec/belajar/terminal/courses_spec.rb +104 -99
  69. data/spec/belajar/terminal/output_spec.rb +44 -39
  70. data/spec/belajar/terminal/setup_spec.rb +1 -3
  71. data/spec/belajar/terminal/solutions_spec.rb +0 -2
  72. data/spec/belajar/terminal/welcome_spec.rb +0 -2
  73. data/spec/belajar/terminal_spec.rb +5 -7
  74. data/spec/belajar/test_example_spec.rb +16 -14
  75. data/spec/belajar/test_result_spec.rb +21 -25
  76. data/spec/belajar/test_spec.rb +11 -12
  77. data/spec/belajar/unit_spec.rb +24 -27
  78. data/spec/belajar/views/chapters_menu_spec.rb +0 -1
  79. data/spec/belajar/views/courses_menu_spec.rb +0 -1
  80. data/spec/belajar/views/menu_spec.rb +1 -2
  81. data/spec/belajar/views/task_view_spec.rb +0 -2
  82. data/spec/belajar/views/units_menu_spec.rb +0 -1
  83. data/spec/belajar/views_spec.rb +0 -1
  84. data/spec/belajar_spec.rb +9 -12
  85. data/spec/path_helpers_spec.rb +11 -12
  86. data/spec/resource_helpers_spec.rb +11 -12
  87. data/spec/spec_helper.rb +3 -4
  88. data/spec/support/macros/content_helpers.rb +16 -17
  89. data/spec/support/macros/mock_helpers.rb +6 -6
  90. data/spec/support/macros/path_helpers.rb +15 -15
  91. data/spec/support/macros/resource_helpers.rb +34 -35
  92. metadata +56 -75
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Belajar::Configuration do
4
-
5
4
  subject { Belajar::Configuration.send(:new) }
6
5
 
7
6
  it { is_expected.to respond_to :solutions_path }
@@ -10,85 +9,90 @@ describe Belajar::Configuration do
10
9
  it { is_expected.to respond_to :courses_path= }
11
10
  it { is_expected.to respond_to :storage_file }
12
11
  it { is_expected.to respond_to :save }
13
- it { is_expected.to respond_to :import! }
12
+ it { is_expected.to respond_to :import }
14
13
  it { is_expected.to respond_to :summary }
15
14
 
16
15
  before do
17
16
  subject.instance_variable_set(:@storage_file, local_storage_file)
17
+ File.open(local_storage_file, 'w')
18
18
  end
19
19
 
20
- describe "#courses_path" do
21
- it "returns the appropriate initial local courses path" do
20
+ describe '#courses_path' do
21
+ it 'returns the appropriate initial local courses path' do
22
22
  courses_path = File.expand_path('~/.belajar/courses', __FILE__)
23
23
  expect(subject.courses_path).to eq courses_path
24
24
  end
25
25
 
26
- it "returns the appropriate set courses path" do
26
+ it 'returns the appropriate set courses path' do
27
27
  subject.courses_path = local_courses_path
28
28
  expect(subject.courses_path).to eq local_courses_path
29
29
  end
30
30
  end
31
31
 
32
- describe "#solutions_path=" do
33
- it "raises an error if the given path is no existent dir" do
34
- expect { subject.solutions_path = "no/existent/dir" }
35
- .to raise_error(Belajar::ConfigurationError)
32
+ describe '#solutions_path=' do
33
+ context 'if the given path is no existent dir' do
34
+ it 'raises a configuration error' do
35
+ expect { subject.solutions_path = 'no/existent/dir' }
36
+ .to raise_error(Belajar::ConfigurationError)
37
+ end
36
38
  end
37
39
  end
38
40
 
39
- describe "#solutions_path" do
40
- it "raises an error if not set" do
41
- expect { subject.solutions_path }
42
- .to raise_error(Belajar::ConfigurationError)
41
+ describe '#solutions_path' do
42
+ context 'if not set' do
43
+ it 'raises an error' do
44
+ expect { subject.solutions_path }
45
+ .to raise_error(Belajar::ConfigurationError)
46
+ end
43
47
  end
44
48
 
45
- it "returns the solutions path if set" do
46
- subject.solutions_path = test_basepath
47
- expect { subject.solutions_path }.not_to raise_error
49
+ context 'if set' do
50
+ it 'returns the solutions path' do
51
+ subject.solutions_path = test_basepath
52
+ expect(subject.solutions_path).to eq test_basepath
53
+ end
48
54
  end
49
55
  end
50
56
 
51
- describe "#storage_path" do
52
- it "returns the appropriate path to the storage file" do
57
+ describe '#storage_path' do
58
+ it 'returns the appropriate path to the storage file' do
53
59
  expect(subject.storage_file).to eq local_storage_file
54
60
  end
55
61
  end
56
62
 
57
- describe "#save" do
58
- it "saves the configured courses path to the belajar store" do
63
+ describe '#save' do
64
+ it 'saves the configured courses path to the belajar store' do
59
65
  subject.courses_path = local_courses_path
60
66
  subject.save
61
67
 
62
68
  expect(QuickStore.store.courses_path).to eq local_courses_path
63
69
  end
64
70
 
65
- it "saves the configured solution_path to the belajar store" do
71
+ it 'saves the configured solution_path to the belajar store' do
66
72
  path = File.join(test_basepath, 'test_solutions')
67
- FileUtils.makedirs(path)
73
+ create_directory(path)
68
74
  subject.solutions_path = path
69
75
  subject.save
70
76
 
71
77
  expect(QuickStore.store.solutions_path).to eq path
72
78
  end
73
79
 
74
- it "does not save the storage file path" do
80
+ it 'does not save the storage file path' do
75
81
  subject.save
76
82
  expect(QuickStore.store.storage_file).to be_nil
77
83
  end
78
84
  end
79
85
 
80
- describe "#import!" do
81
- context "with non-existent belajar store entries:" do
82
- before do
83
- FileUtils.rm(local_storage_file) if File.exist?(local_storage_file)
84
- end
86
+ describe '#import' do
87
+ context 'with non-existent belajar store entries:' do
88
+ before { remove_file(local_storage_file) }
85
89
 
86
- it "uses the default configuration" do
87
- QuickStore.store.courses_path = nil
90
+ it 'uses the default configuration' do
91
+ QuickStore.store.courses_path = nil
88
92
  QuickStore.store.solutions_path = nil
89
93
  subject.instance_variable_set(:@courses_path, local_courses_path)
90
94
 
91
- loaded_config = subject.import!
95
+ loaded_config = subject.import
92
96
 
93
97
  expect(loaded_config.courses_path).to eq local_courses_path
94
98
  expect { loaded_config.solutions_path }
@@ -96,17 +100,18 @@ describe Belajar::Configuration do
96
100
  end
97
101
  end
98
102
 
99
- context "with existing belajar storage file:" do
100
- it "returns a Belajar::Configuration" do
101
- expect(subject.import!).to be_a Belajar::Configuration
103
+ context 'with existing belajar storage file:' do
104
+ it 'returns a Belajar::Configuration' do
105
+ expect(subject.import).to be_a Belajar::Configuration
102
106
  end
103
107
 
104
- it "loads the belajar store entries into the configuration" do
105
- wanted_courses_path = "/courses/path"
108
+ it 'loads the belajar store entries into the configuration' do
109
+ wanted_courses_path = '/courses/path'
106
110
  wanted_solutions_path = solutions_basepath
107
- temp_solutions_path = File.join(solutions_basepath, 'temp')
108
- FileUtils.makedirs(wanted_solutions_path)
109
- FileUtils.makedirs(temp_solutions_path)
111
+ temp_solutions_path = File.join(solutions_basepath, 'temp')
112
+
113
+ create_directory(wanted_solutions_path)
114
+ create_directory(temp_solutions_path)
110
115
 
111
116
  # save wanted settings
112
117
  subject.courses_path = wanted_courses_path
@@ -114,11 +119,11 @@ describe Belajar::Configuration do
114
119
  subject.save
115
120
 
116
121
  # overwrite in memory settings
117
- subject.courses_path = '/some/other/path/'
122
+ subject.courses_path = '/some/other/path/'
118
123
  subject.solutions_path = temp_solutions_path
119
124
 
120
125
  # fetch stored settings
121
- subject.import!
126
+ subject.import
122
127
  expect(File.exist?(local_storage_file)).to be_truthy
123
128
  expect(subject.courses_path).to eq wanted_courses_path
124
129
  expect(subject.solutions_path).to eq wanted_solutions_path
@@ -128,34 +133,33 @@ describe Belajar::Configuration do
128
133
 
129
134
  describe '#summary' do
130
135
  before do
131
- subject.courses_path = "wanted/courses/path"
136
+ subject.courses_path = 'wanted/courses/path'
132
137
  subject.solutions_path = solutions_basepath
133
- @summary = subject.summary
138
+ @summary = subject.summary
134
139
  end
135
140
 
136
- it "returns a string" do
141
+ it 'returns a string' do
137
142
  expect(@summary).to be_a String
138
143
  end
139
144
 
140
- it "returns a string with all properties but @configuration_file" do
145
+ it 'returns a string with all properties but @configuration_file' do
141
146
  expect(@summary.lines.count).to eq subject.instance_variables.count - 1
142
147
  end
143
148
 
144
- it "returns a string including the courses path" do
149
+ it 'returns a string including the courses path' do
145
150
  expect(@summary =~ /courses path/).to be_truthy
146
151
  end
147
152
 
148
- it "returns a string including the courses path" do
153
+ it 'returns a string including the courses path' do
149
154
  expect(@summary =~ /solutions path/).to be_truthy
150
155
  end
151
156
  end
152
157
 
153
158
  describe '#initial_course' do
154
- it { is_expected.to respond_to :initial_course }
159
+ it { is_expected.to respond_to :initial_course }
155
160
 
156
- it "returns the initial course github repo partial path" do
157
- expect(subject.initial_course).to eq 'wong-bejo/Get_started_with_Ruby'
161
+ it 'returns the initial course github repo partial path' do
162
+ expect(subject.initial_course).to eq 'wong-bejo/Belajar_Ruby'
158
163
  end
159
164
  end
160
-
161
165
  end
@@ -1,23 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Belajar::Congratulator do
4
-
5
- it "responds to #message" do
4
+ it 'responds to #message' do
6
5
  expect(Belajar::Congratulator).to respond_to :message
7
6
  end
8
7
 
9
- describe "#message" do
10
- it "returns a string" do
8
+ describe '#message' do
9
+ it 'returns a string' do
11
10
  expect(Belajar::Congratulator.message).to be_a String
12
11
  end
13
12
 
14
- it "returns a random congratulation method" do
15
- messages = 1.upto(10).map { |i| Belajar::Congratulator.message }
13
+ it 'returns a random congratulation method' do
14
+ messages = 1.upto(10).map { |_| Belajar::Congratulator.message }
16
15
  expect(messages.uniq.count).to be > 1
17
16
  end
18
17
 
19
- it "receives the congratulation texts from a Terminal text" do
20
- expect(Belajar::Terminal).to receive(:text).with(:congratulations) { '' }
18
+ it 'receives the congratulation texts from a Terminal text' do
19
+ expect(Belajar::Terminal)
20
+ .to receive(:text)
21
+ .with(:congratulations)
22
+ .and_return('')
23
+
21
24
  Belajar::Congratulator.message
22
25
  end
23
26
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Belajar::Course do
4
-
5
4
  it { is_expected.to respond_to :title }
6
5
  it { is_expected.to respond_to :chapters }
7
6
  it { is_expected.to respond_to :path }
@@ -22,73 +21,82 @@ describe Belajar::Course do
22
21
 
23
22
  subject { Belajar::Course.new(course_path) }
24
23
 
25
- it "responds to ::unzip" do
24
+ it 'responds to .unzip' do
26
25
  expect(Belajar::Course).to respond_to :unzip
27
26
  end
28
27
 
29
- it "has the prescribed title" do
28
+ it 'has the prescribed title' do
30
29
  expect(subject.title).to eq course_titles.first
31
30
  end
32
31
 
33
- it "has the prescribed path" do
32
+ it 'has the prescribed path' do
34
33
  expect(subject.path).to eq course_path
35
34
  end
36
35
 
37
- it "is not started by default" do
38
- expect(subject.started?).to be_falsey
36
+ it 'is not started by default' do
37
+ expect(subject.started?).to be false
39
38
  end
40
39
 
41
- it "is not mastered by default" do
42
- expect(subject.mastered?).to be_falsey
40
+ it 'is not mastered by default' do
41
+ expect(subject.mastered?).to be false
43
42
  end
44
43
 
45
- describe "#chapters" do
46
- it "loads the prescribed number of chapters" do
44
+ describe '#chapters' do
45
+ it 'loads the prescribed number of chapters' do
47
46
  expect(subject.chapters.count).to eq available_chapters(course_path).count
48
47
  end
49
48
 
50
- it "lazy-loads the chapters" do
49
+ it 'lazy-loads the chapters' do
51
50
  expect(subject.instance_variable_get(:@chapters)).to be_nil
52
51
  subject.chapters
53
52
  expect(subject.instance_variable_get(:@chapters)).not_to be_nil
54
53
  end
55
54
  end
56
55
 
57
- describe "#started?" do
58
- it "returns true if at least one chapter has been started" do
59
- allow(subject.chapters.first).to receive(:started?) { true }
56
+ describe '#started?' do
57
+ it 'returns true if at least one chapter has been started' do
58
+ allow(subject.chapters.first).to receive(:started?).and_return(true)
60
59
  expect(subject.started?).to be true
61
60
  end
62
61
 
63
- it "returns false if no chapter has been started" do
64
- allow_any_instance_of(Belajar::Chapter).to receive(:started?) { false }
62
+ it 'returns false if no chapter has been started' do
63
+ allow_any_instance_of(Belajar::Chapter)
64
+ .to receive(:started?)
65
+ .and_return(false)
66
+
65
67
  expect(subject.started?).to be false
66
68
  end
67
69
  end
68
70
 
69
- describe "#mastered?" do
70
- it "returns true if all chapters have been mastered" do
71
- allow_any_instance_of(Belajar::Chapter).to receive(:mastered?) { true }
71
+ describe '#mastered?' do
72
+ it 'returns true if all chapters have been mastered' do
73
+ allow_any_instance_of(Belajar::Chapter)
74
+ .to receive(:mastered?)
75
+ .and_return(true)
76
+
72
77
  expect(subject.mastered?).to be true
73
78
  end
74
79
 
75
- it "returns false unless all chapters have been mastered" do
76
- allow_any_instance_of(Belajar::Chapter).to receive(:mastered?) { false }
77
- allow(subject.chapters.first).to receive(:mastered?) { true }
80
+ it 'returns false unless all chapters have been mastered' do
81
+ allow_any_instance_of(Belajar::Chapter)
82
+ .to receive(:mastered?)
83
+ .and_return(false)
84
+
85
+ allow(subject.chapters.first).to receive(:mastered?).and_return(true)
78
86
  expect(subject.mastered?).to be false
79
87
  end
80
88
  end
81
89
 
82
- describe "#key" do
83
- it "returns the courses store key for the given key name" do
84
- allow(subject).to receive(:title) { '1-Course title' }
85
- key = "courses/course_title/some_key"
90
+ describe '#key' do
91
+ it 'returns the courses store key for the given key name' do
92
+ allow(subject).to receive(:title).and_return('1-Course title')
93
+ key = 'courses/course_title/some_key'
86
94
  expect(subject.key('1-some Key')).to eq key
87
95
  end
88
96
  end
89
97
 
90
- describe "#author" do
91
- it "returns the author of Github courses form the store" do
98
+ describe '#author' do
99
+ it 'returns the author of Github courses form the store' do
92
100
  author = 'author'
93
101
  QuickStore.store.set(subject.key(:author), author)
94
102
 
@@ -97,77 +105,87 @@ describe Belajar::Course do
97
105
  end
98
106
  end
99
107
 
100
- describe "::unzip" do
108
+ describe '.unzip' do
101
109
  before do
102
110
  Belajar.config.courses_path = local_courses_path
103
- @zip_file_name = "unzip/repo.zip"
111
+
112
+ @zip_file_name = 'unzip/repo.zip'
104
113
  @zip_file_path = File.join(courses_basepath, @zip_file_name)
105
- @file_content = prepare_download(@zip_file_name)
114
+ @file_content = prepare_download(@zip_file_name)
106
115
  end
107
116
 
108
117
  after do
109
118
  cleanup_download(@zip_file_name)
110
119
  dir = File.dirname(@zip_file_path)
111
- FileUtils.rm_r(dir) if Dir.exist?(dir)
120
+ remove_directory(dir)
112
121
  end
113
122
 
114
123
  def expect_course_dirs_exists_to_be(boolean)
115
124
  unit_dirs(course_dir_names.first).each do |chapter_dirs|
116
125
  chapter_dirs.each do |dir|
117
- path = [dir.split('/')[0..-4], 'unzip', dir.split('/')[-3..-1]].join('/')
126
+ path = [
127
+ dir.split('/')[0..-4],
128
+ 'unzip',
129
+ dir.split('/')[-3..-1]
130
+ ].join('/')
131
+
118
132
  expect(Dir.exist?(path)).to be boolean
119
133
  end
120
134
  end
121
135
  end
122
136
 
123
- it "unzips a course zip file" do
137
+ it 'unzips a course zip file' do
124
138
  expect_course_dirs_exists_to_be false
125
139
  Belajar::Course.unzip(@zip_file_path)
126
140
  expect_course_dirs_exists_to_be true
127
141
  end
128
142
 
129
- it "returns the unzipped course" do
130
- dir = course_dirs.first
131
- path = File.join(File.dirname(dir), 'unzip', File.basename(dir))
132
- course = Belajar::Course.new(path)
143
+ it 'returns the unzipped course' do
144
+ dir = course_dirs.first
145
+ path = File.join(File.dirname(dir), 'unzip', File.basename(dir))
133
146
 
134
- expect(Belajar::Course.unzip(@zip_file_path).to_json).to eql course.to_json
147
+ actual = Belajar::Course.unzip(@zip_file_path)
148
+ expected = Belajar::Course.new(path)
149
+
150
+ expect(actual.path).to eq expected.path
151
+ expect(actual.title).to eq expected.title
152
+ expect(actual.author).to eq expected.author
135
153
  end
136
154
 
137
- it "removes the zip file" do
155
+ it 'removes the zip file' do
138
156
  expect(File.exist?(@zip_file_path)).to be true
139
157
  Belajar::Course.unzip(@zip_file_path)
140
158
  expect(File.exist?(@zip_file_path)).to be false
141
159
  end
142
160
 
143
- context "with the same course already available:" do
161
+ context 'with the same course already available' do
144
162
  before do
145
163
  dir = course_dirs.first
146
164
  @path = File.join(File.dirname(dir), 'unzip', File.basename(dir))
147
165
  @old_chapter_dir = File.join(@path, 'Old_chapter')
148
166
 
149
- FileUtils.mkdir_p(@old_chapter_dir)
167
+ create_directory(@old_chapter_dir)
150
168
  end
151
169
 
152
- it "overwrites all chapters" do
170
+ it 'overwrites all chapters' do
153
171
  expect(Dir.exist?(@old_chapter_dir)).to be true
154
172
  Belajar::Course.unzip(@zip_file_path)
155
173
  expect(Dir.exist?(@old_chapter_dir)).to be false
156
174
  end
157
175
 
158
- context "if an errior occurs" do
176
+ context 'if an error occurs' do
159
177
  before do
160
178
  allow_any_instance_of(Zip::File)
161
- .to receive(:extract) { raise Exception.new }
179
+ .to receive(:extract) { raise StandardError.new, 'error' }
162
180
  end
163
181
 
164
- it "restores an old state if an error occurs" do
182
+ it 'restores an old state' do
165
183
  Belajar::Course.unzip(@zip_file_path)
166
184
  expect(Dir.exist?(@old_chapter_dir)).to be true
167
185
  expect(Dir.exist?("#{@path}_old")).to be false
168
186
  end
169
187
 
170
- it "keeps the zip file if an error occurs" do
188
+ it 'keeps the zip file' do
171
189
  expect(File.exist?(@zip_file_path)).to be true
172
190
  Belajar::Course.unzip(@zip_file_path)
173
191
  expect(File.exist?(@zip_file_path)).to be true
@@ -175,12 +193,12 @@ describe Belajar::Course do
175
193
  end
176
194
  end
177
195
 
178
- context "with the github_repo option:" do
196
+ context 'with the github_repo option:' do
179
197
  before { @github_course_dir = prepare_github_course }
180
- after { FileUtils.rm_r(@github_course_dir) }
198
+ after { remove_directory(@github_course_dir) }
181
199
 
182
- it "removes the '-master' from the root directory" do
183
- zip_file_name = "unzip/repo-master.zip"
200
+ it 'removes the "-master" from the root directory' do
201
+ zip_file_name = 'unzip/repo-master.zip'
184
202
  zip_file_path = File.join(courses_basepath, zip_file_name)
185
203
  prepare_github_download(zip_file_name)
186
204
 
@@ -189,7 +207,12 @@ describe Belajar::Course do
189
207
 
190
208
  unit_dirs("#{course_dir_names.first}-master").each do |chapter_dirs|
191
209
  chapter_dirs.each do |dir|
192
- path = [dir.split('/')[0..-4], 'unzip', dir.split('/')[-3..-1]].join('/')
210
+ path = [
211
+ dir.split('/')[0..-4],
212
+ 'unzip',
213
+ dir.split('/')[-3..-1]
214
+ ].join('/')
215
+
193
216
  expect(Dir.exist?(path)).to be false
194
217
  end
195
218
  end