From: Ben Beltran Date: Sun, 7 Oct 2012 23:42:26 +0000 (-0500) Subject: Add specs, startin with util X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/commitdiff_plain/f1e240a3c951aceb1d5d100c199e5a5b8d5eb6ec Add specs, startin with util --- diff --git a/spec/bin/lrc_spec.rb b/spec/bin/lrc_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/configuration_spec.rb b/spec/lib/lyricli/configuration_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/exceptions_spec.rb b/spec/lib/lyricli/exceptions_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/lyricli_spec.rb b/spec/lib/lyricli/lyricli_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/lyrics_engine_spec.rb b/spec/lib/lyricli/lyrics_engine_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/source_manager_spec.rb b/spec/lib/lyricli/source_manager_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/sources/arguments.rb b/spec/lib/lyricli/sources/arguments.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/sources/itunes.rb b/spec/lib/lyricli/sources/itunes.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/sources/rdio.rb b/spec/lib/lyricli/sources/rdio.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/sources_spec.rb b/spec/lib/lyricli/sources_spec.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/lib/lyricli/util_spec.rb b/spec/lib/lyricli/util_spec.rb new file mode 100644 index 0000000..3d68ec4 --- /dev/null +++ b/spec/lib/lyricli/util_spec.rb @@ -0,0 +1,42 @@ +require "rspec" +require "lyricli" + +describe Lyricli::Util do + before :each do + class TestClass + include Lyricli::Util + end + + module Lyricli + module Sources + class ParsedClass + end + end + end + + @c = TestClass.new + end + + describe "#camelize" do + it "should convert snake_case to CamelCase" do + expect(@c.camelize("test_string")).to eq("TestString") + end + end + + describe "#parse_class" do + it "should parse classes under the Source namespace" do + expect(@c.parse_class("ParsedClass")).to eq(Lyricli::Sources::ParsedClass) + end + + it "should return nil for nonexistent classes" do + expect(@c.parse_class("non_existent_class")).to eq(nil) + end + end + + describe "#sanitize_param" do + it "should escape weird characters, but conserve the +" do + str = "one two+three /?&" + expect(@c.sanitize_param(str)).to eq("one+two+three+%2F%3F%26") + end + end +end diff --git a/spec/lib/lyricli_spec.rb b/spec/lib/lyricli_spec.rb new file mode 100644 index 0000000..e69de29