]> git.r.bdr.sh - rbdr/lyricli.rb/blob - spec/lib/lyricli/util_spec.rb
Add specs, startin with util
[rbdr/lyricli.rb] / spec / lib / lyricli / util_spec.rb
1 require "rspec"
2 require "lyricli"
3
4 describe Lyricli::Util do
5 before :each do
6 class TestClass
7 include Lyricli::Util
8 end
9
10 module Lyricli
11 module Sources
12 class ParsedClass
13 end
14 end
15 end
16
17 @c = TestClass.new
18 end
19
20 describe "#camelize" do
21 it "should convert snake_case to CamelCase" do
22 expect(@c.camelize("test_string")).to eq("TestString")
23 end
24 end
25
26 describe "#parse_class" do
27 it "should parse classes under the Source namespace" do
28 expect(@c.parse_class("ParsedClass")).to eq(Lyricli::Sources::ParsedClass)
29 end
30
31 it "should return nil for nonexistent classes" do
32 expect(@c.parse_class("non_existent_class")).to eq(nil)
33 end
34 end
35
36 describe "#sanitize_param" do
37 it "should escape weird characters, but conserve the +" do
38 str = "one two+three /?&"
39 expect(@c.sanitize_param(str)).to eq("one+two+three+%2F%3F%26")
40 end
41 end
42 end