mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
added a very simple test suite
This commit is contained in:
parent
a8a1c4d1c3
commit
047cc71b0d
|
@ -1,9 +1,35 @@
|
||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
describe Irs do
|
describe CLI do
|
||||||
# TODO: Write tests
|
# TODO: Write tests
|
||||||
|
|
||||||
it "works" do
|
it "can show help" do
|
||||||
false.should eq(true)
|
run_CLI_with_args(["--help"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can show version" do
|
||||||
|
run_CLI_with_args(["--version"])
|
||||||
|
end
|
||||||
|
|
||||||
|
# !!TODO: make a long and short version of the test suite
|
||||||
|
# TODO: makes so this doesn't need user input
|
||||||
|
it "can install ytdl and ffmpeg binaries" do
|
||||||
|
# run_CLI_with_args(["--install"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can show config file loc" do
|
||||||
|
run_CLI_with_args(["--config"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can download a single song" do
|
||||||
|
run_CLI_with_args(["--song", "Bohemian Rhapsody", "--artist", "Queen"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can download an album" do
|
||||||
|
run_CLI_with_args(["--artist", "Arctic Monkeys", "--album", "Da Frame 2R / Matador"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can download a playlist" do
|
||||||
|
run_CLI_with_args(["--artist", "prakkillian", "--playlist", "IRS Testing"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,10 @@
|
||||||
require "spec"
|
require "spec"
|
||||||
require "../src/irs"
|
|
||||||
|
# https://github.com/mosop/stdio
|
||||||
|
|
||||||
|
require "../src/bottle/cli"
|
||||||
|
|
||||||
|
def run_CLI_with_args(argv : Array(String))
|
||||||
|
cli = CLI.new(argv)
|
||||||
|
cli.act_on_args
|
||||||
|
end
|
|
@ -73,22 +73,17 @@ class CLI
|
||||||
|
|
||||||
if @args["help"]? || @args.keys.size == 0
|
if @args["help"]? || @args.keys.size == 0
|
||||||
help
|
help
|
||||||
exit
|
|
||||||
elsif @args["version"]?
|
elsif @args["version"]?
|
||||||
version
|
version
|
||||||
exit
|
|
||||||
elsif @args["install"]?
|
elsif @args["install"]?
|
||||||
YdlBinaries.get_both(Config.binary_location)
|
YdlBinaries.get_both(Config.binary_location)
|
||||||
exit
|
|
||||||
elsif @args["config"]?
|
elsif @args["config"]?
|
||||||
puts ENV["IRS_CONFIG_LOCATION"]?
|
puts ENV["IRS_CONFIG_LOCATION"]?
|
||||||
exit
|
|
||||||
elsif @args["song"]? && @args["artist"]?
|
elsif @args["song"]? && @args["artist"]?
|
||||||
s = Song.new(@args["song"], @args["artist"])
|
s = Song.new(@args["song"], @args["artist"])
|
||||||
s.provide_client_keys(Config.client_key, Config.client_secret)
|
s.provide_client_keys(Config.client_key, Config.client_secret)
|
||||||
s.grab_it(@args["url"]?)
|
s.grab_it(@args["url"]?)
|
||||||
s.organize_it(Config.music_directory)
|
s.organize_it(Config.music_directory)
|
||||||
exit
|
|
||||||
elsif @args["album"]? && @args["artist"]?
|
elsif @args["album"]? && @args["artist"]?
|
||||||
a = Album.new(@args["album"], @args["artist"])
|
a = Album.new(@args["album"], @args["artist"])
|
||||||
a.provide_client_keys(Config.client_key, Config.client_secret)
|
a.provide_client_keys(Config.client_key, Config.client_secret)
|
||||||
|
@ -108,7 +103,6 @@ class CLI
|
||||||
else
|
else
|
||||||
puts Style.red("Those arguments don't do anything when used that way.")
|
puts Style.red("Those arguments don't do anything when used that way.")
|
||||||
puts "Type `irs -h` to see usage."
|
puts "Type `irs -h` to see usage."
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ module Youtube
|
||||||
|
|
||||||
if yt_initial_data == JSON.parse("{}")
|
if yt_initial_data == JSON.parse("{}")
|
||||||
puts "Youtube has changed the way it organizes its webpage, submit a bug"
|
puts "Youtube has changed the way it organizes its webpage, submit a bug"
|
||||||
puts "on https://github.com/cooperhammond/irs"
|
puts "saying it has done so on https://github.com/cooperhammond/irs"
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue