Created
March 4, 2023 09:58
-
-
Save davidteren/ffb070b26f7e298dca7c4a936ef5049c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'lpx_links' | |
describe "lpx_links" do | |
describe "#generate_links" do | |
it "generates download links" do | |
expect { generate_links }.to output("Download links generated.\n").to_stdout | |
end | |
end | |
describe "#download_packages" do | |
it "downloads packages" do | |
expect { download_packages(false) }.to output("Packages downloaded.\n").to_stdout | |
end | |
it "downloads mandatory packages only" do | |
expect { download_packages(true) }.to output("Packages downloaded.\n").to_stdout | |
end | |
end | |
describe "#install_packages" do | |
it "installs packages" do | |
expect { install_packages(false) }.to output("Packages installed.\n").to_stdout | |
end | |
it "installs mandatory packages only" do | |
expect { install_packages(true) }.to output("Packages installed.\n").to_stdout | |
end | |
end | |
describe "CLI" do | |
context "when no options are specified" do | |
it "displays a menu of options" do | |
expect do | |
allow_any_instance_of(Kernel).to receive(:gets).and_return("4") | |
load 'lpx_links.rb' | |
end.to output(/Select an option:/).to_stdout | |
end | |
end | |
context "when option -g is specified" do | |
it "calls #generate_links" do | |
expect_any_instance_of(Object).to receive(:generate_links) | |
load 'lpx_links.rb', true, ['-g'] | |
end | |
end | |
context "when option -d is specified" do | |
it "calls #download_packages without mandatory-only flag" do | |
expect_any_instance_of(Object).to receive(:download_packages).with(false) | |
load 'lpx_links.rb', true, ['-d'] | |
end | |
it "calls #download_packages with mandatory-only flag" do | |
expect_any_instance_of(Object).to receive(:download_packages).with(true) | |
load 'lpx_links.rb', true, ['-d', '-m'] | |
end | |
end | |
context "when option -i is specified" do | |
it "calls #install_packages without mandatory-only flag" do | |
expect_any_instance_of(Object).to receive(:install_packages).with(false) | |
load 'lpx_links.rb', true, ['-i'] | |
end | |
it "calls #install_packages with mandatory-only flag" do | |
expect_any_instance_of(Object).to receive(:install_packages).with(true) | |
load 'lpx_links.rb', true, ['-i', '-m'] | |
end | |
end | |
context "when option -h is specified" do | |
it "displays usage help" do | |
expect do | |
load 'lpx_links.rb', true, ['-h'] | |
end.to output(/Usage: lpx_links\.rb/).to_stdout | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment