This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
xapit_spec.rb
43 lines (37 loc) · 1.49 KB
/
xapit_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "spec_helper"
describe Xapit do
it "has default config settings" do
Xapit.config[:enabled].should eq(true)
Xapit.config[:spelling].should eq(true)
Xapit.config[:stemming].should eq("english")
end
it "can be enabled" do
Xapit.config[:enabled] = false
Xapit.enable
Xapit.config[:enabled].should eq(true)
end
it "loads and reloads a configuration file via load_config" do
Xapit.load_config("spec/fixtures/xapit.yml", "development")
Xapit.config[:database_path].should eq("development_database")
Xapit.config[:database_path] = "foo"
Xapit.reload
Xapit.config[:database_path].should eq("development_database")
end
it "raises an exception when accessing the database while disabled" do
Xapit.config[:enabled] = false
lambda { Xapit.database }.should raise_exception(Xapit::Disabled)
end
it "allows changing the query class" do
Xapit.query_class.should eq(Xapit::Server::Query)
Xapit.config[:query_class] = "String"
Xapit.query_class.should eq(String)
end
it "serialize_value converts time and numbers properly" do
time = 2.days.ago
Xapit.serialize_value(time).should eq(Xapian.sortable_serialise(time.to_i))
Xapit.serialize_value(time.to_json).should eq(Xapian.sortable_serialise(time.to_i))
Xapit.serialize_value(123).should eq(Xapian.sortable_serialise(123))
Xapit.serialize_value("123").should eq(Xapian.sortable_serialise(123))
Xapit.serialize_value("1234-56-78foo").should eq("1234-56-78foo")
end
end