spec/lib/gummi/repository_spec.rb in gummi-0.0.6 vs spec/lib/gummi/repository_spec.rb in gummi-0.0.7
- old
+ new
@@ -34,14 +34,13 @@
end
describe ".get" do
context "existing record" do
- let (:db_person) { DB::Person.new(name: 'Buzz Lightyear') }
+ let (:db_person) { DB::Person.create(name: 'Buzz Lightyear') }
it "should return an entity" do
- db_person.overwrite
person = People.get(db_person.id)
person.id.should == db_person.id
end
end
@@ -51,7 +50,32 @@
person.should be_nil
end
end
end
+ describe ".search" do
+
+ before(:each) do
+ DB::Person.create(name: 'Buzz Lightyear')
+ DB::Person.create(name: 'Woody')
+ Gummi::DefaultIndex.refresh
+ end
+
+ it "should find the correct documents" do
+ result = People.search do |search|
+ search.query_string = "Woody"
+ end
+ result.total.should == 1
+ result.records.first.name.should == "Woody"
+ end
+
+ it "should convert the result to entities" do
+ result = People.search do |search|
+ search.query_string = "Woody"
+ end
+ woody = result.records.first
+ woody.converted_name.should == 'ydooW'
+ woody.should be_a Person
+ end
+ end
end
\ No newline at end of file