]> git.r.bdr.sh - rbdr/lyricli.rb/commitdiff
Merge branch 'master' of github.com:benbeltran/lyricli
authorBen Beltran <redacted>
Thu, 13 Nov 2014 23:19:58 +0000 (16:19 -0700)
committerBen Beltran <redacted>
Thu, 13 Nov 2014 23:19:58 +0000 (16:19 -0700)
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..8f999a7
--- /dev/null
@@ -0,0 +1,25 @@
+require "rspec"
+require "lyricli"
+
+describe Lyricli::SourceManager do
+  before :each do
+    # Stub the configuration
+    @example_configuration = {"enabled_sources" => "test_class"}
+    Configuration.stub(:'[]').and_return(@example_configuration)
+    Configuration.stub(:delete)
+
+    # Stub the test class.
+    module Lyricli
+      module Sources
+        module TestClass
+        end
+      end
+    end
+
+    @example_artist = {:artist => "The Shins", :song => "Know Your Onion"}
+
+    Lyricli::Sources::TestClass.stub(:enable)
+    Lyricli::Sources::TestClass.stub(:reset)
+    Lyricli::Sources::TestClass.stub(:current_track).and_return(@example_artist)
+  end
+end
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