]> git.r.bdr.sh - rbdr/lyricli.rb/commitdiff
Add specs, startin with util
authorBen Beltran <redacted>
Sun, 7 Oct 2012 23:42:26 +0000 (18:42 -0500)
committerBen Beltran <redacted>
Sun, 7 Oct 2012 23:42:26 +0000 (18:42 -0500)
12 files changed:
spec/bin/lrc_spec.rb [new file with mode: 0644]
spec/lib/lyricli/configuration_spec.rb [new file with mode: 0644]
spec/lib/lyricli/exceptions_spec.rb [new file with mode: 0644]
spec/lib/lyricli/lyricli_spec.rb [new file with mode: 0644]
spec/lib/lyricli/lyrics_engine_spec.rb [new file with mode: 0644]
spec/lib/lyricli/source_manager_spec.rb [new file with mode: 0644]
spec/lib/lyricli/sources/arguments.rb [new file with mode: 0644]
spec/lib/lyricli/sources/itunes.rb [new file with mode: 0644]
spec/lib/lyricli/sources/rdio.rb [new file with mode: 0644]
spec/lib/lyricli/sources_spec.rb [new file with mode: 0644]
spec/lib/lyricli/util_spec.rb [new file with mode: 0644]
spec/lib/lyricli_spec.rb [new file with mode: 0644]

diff --git a/spec/bin/lrc_spec.rb b/spec/bin/lrc_spec.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/configuration_spec.rb b/spec/lib/lyricli/configuration_spec.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/exceptions_spec.rb b/spec/lib/lyricli/exceptions_spec.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/lyricli_spec.rb b/spec/lib/lyricli/lyricli_spec.rb
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/sources/arguments.rb b/spec/lib/lyricli/sources/arguments.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/sources/itunes.rb b/spec/lib/lyricli/sources/itunes.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/sources/rdio.rb b/spec/lib/lyricli/sources/rdio.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/sources_spec.rb b/spec/lib/lyricli/sources_spec.rb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/spec/lib/lyricli/util_spec.rb b/spec/lib/lyricli/util_spec.rb
new file mode 100644 (file)
index 0000000..3d68ec4
--- /dev/null
@@ -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 (file)
index 0000000..e69de29