spec/learn_open/opener_spec.rb in learn-open-1.2.5 vs spec/learn_open/opener_spec.rb in learn-open-1.2.6

- old
+ new

@@ -8,67 +8,18 @@ after do path = File.join(__dir__, "..", "home_dir", "code") FileUtils.rm_rf(path) end - context "with .cloned_labs file" do - after do - cloned_labs = "#{LearnOpen::Opener::HOME_DIR}/.cloned_labs" - FileUtils.rm(cloned_labs) if File.exists?(cloned_labs) + it "returns true if .git directory for lab exists" do + expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling") + FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling/.git") - syncing_started = "#{LearnOpen::Opener::HOME_DIR}/.syncing_started" - FileUtils.rm(syncing_started) if File.exists?(syncing_started) - end - - it "returns true if lab is in the .cloned_labs file" do - expect(opener).to receive(:repo_dir).at_least(:once).and_return("js-rubber-duck-wrangling") - - File.open("#{LearnOpen::Opener::HOME_DIR}/.cloned_labs", "w+") do |f| - f.puts("js-rubber-duck-wrangling") - end - - File.open("#{LearnOpen::Opener::HOME_DIR}/.syncing_started", "w+") do |f| - f.puts("done") - end - - FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling") - - expect(opener.repo_exists?).to be_truthy - end - - it "returns false if lab is not in the .cloned_labs file" do - File.open("#{LearnOpen::Opener::HOME_DIR}/.syncing_started", "w+") do |f| - f.puts("done") - end - expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling") - expect(opener.repo_exists?).to be_falsy - end - - context "before filesyncing starts" do - it "waits for .syncing_started " do - File.open("#{LearnOpen::Opener::HOME_DIR}/.cloned_labs", "w+") do |f| - f.puts("js-rubber-duck-wrangling") - end - - FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling") - expect do - Timeout::timeout(2) { opener.repo_exists? } - end.to raise_error(Timeout::Error) - end - end + expect(opener.repo_exists?).to be_truthy end - context "without .cloned_labs file" do - it "returns true if directory for lab exists" do - expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling") - FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling") - - expect(opener.repo_exists?).to be_truthy - end - - it "returns false if directory for lab doesn't exists" do - expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling") - expect(opener.repo_exists?).to be_falsy - end + it "returns false if directory for lab doesn't exists" do + expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling") + expect(opener.repo_exists?).to be_falsy end end end