forked from pat/thinking-sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shifting initialisation of results into collection, and adding each_w…
…ith_* methods
- Loading branch information
Showing
5 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec/spec_helper' | ||
|
||
describe ThinkingSphinx::Collection do | ||
it "should return items paired to their attribute values" do | ||
results = Person.search "" | ||
results.should_not be_empty | ||
results.each_with_sphinx_internal_id do |result, id| | ||
result.id.should == id | ||
end | ||
end | ||
|
||
it "should return items paired with their weighting" do | ||
results = Person.search "Ellie Ford", :match_mode => :any | ||
results.should_not be_empty | ||
results.each_with_weighting do |result, weight| | ||
result.should be_kind_of(Person) | ||
weight.should be_kind_of(Integer) | ||
end | ||
end | ||
|
||
it "should return items paired with their count if grouping" do | ||
results = Person.search :group_function => :attr, :group_by => "birthday" | ||
results.should_not be_empty | ||
results.each_with_count do |result, count| | ||
result.should be_kind_of(Person) | ||
count.should be_kind_of(Integer) | ||
end | ||
end | ||
|
||
it "should return items paired with their count and group value" do | ||
results = Person.search :group_function => :attr, :group_by => "birthday" | ||
results.should_not be_empty | ||
results.each_with_group_and_count do |result, group, count| | ||
result.should be_kind_of(Person) | ||
# sometimes the grouping value will be nil/null | ||
group.should be_kind_of(Integer) unless group.nil? | ||
count.should be_kind_of(Integer) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters