summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMatt Gleeson <mgleeson@atlassian.com>2013-09-30 16:32:56 -0700
committerMatt Gleeson <mgleeson@atlassian.com>2013-09-30 16:32:56 -0700
commit49f6be7fcd62cdf8f2f6acd4c343c88789ecee1a (patch)
tree5e88134c7fe06aa5aa5ed440661e62f5f70ce2de /spec
parent57f02150013c08bd121c51999ac2bbfb468e9f7b (diff)
downloadchef-zero-49f6be7fcd62cdf8f2f6acd4c343c88789ecee1a.tar.gz
add support for wildcards
Diffstat (limited to 'spec')
-rw-r--r--spec/search_spec.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/spec/search_spec.rb b/spec/search_spec.rb
index 32d56e4..df0522c 100644
--- a/spec/search_spec.rb
+++ b/spec/search_spec.rb
@@ -11,15 +11,22 @@ describe ChefZero::Solr::SolrParser do
docs
end
+ def search_for(query)
+ q = ChefZero::Solr::SolrParser.new(query).parse
+ all_docs.select {|doc| q.matches_doc?(doc) }
+ end
+
it "handles terms" do
- q = ChefZero::Solr::SolrParser.new('foo:d').parse
- results = all_docs.select {|doc| q.matches_doc?(doc) }
- results.size.should eq(1)
+ search_for('foo:d').size.should eq(1)
end
it "handles ranges" do
- q = ChefZero::Solr::SolrParser.new('foo:[a TO c]').parse
- results = all_docs.select {|doc| q.matches_doc?(doc) }
- results.size.should eq(1)
+ search_for('foo:[a TO c]').size.should eq(1)
+ end
+
+ it "handles wildcard ranges" do
+ search_for('foo:[* TO c]').size.should eq(1)
+ search_for('foo:[c TO *]').size.should eq(1)
+ search_for('foo:[* TO *]').size.should eq(2)
end
end