spec/spotlight_query_spec.rb in spotlight-0.0.4 vs spec/spotlight_query_spec.rb in spotlight-0.0.5

- old
+ new

@@ -1,15 +1,27 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') +require 'tempfile' describe Spotlight::Query do before do @query = Spotlight::Query.new('kMDItemDisplayName = "spotlight_query_spec.rb"') end it "should create query from saved search" do query = Spotlight::Query.from_saved_search(fixture('test.savedSearch')) query.query_string.should eql('((true) && (true)) && ((* = "test*"cdw || kMDItemTextContent = "test*"cdw))') query.scopes.should eql(['kMDQueryScopeComputer']) + end + + it "should create saved search from query" do + tempfile = Tempfile.new('saved_search') + + @query.scopes << '/foo/bar' + @query.to_saved_search(tempfile.path) + + plist = Plist::parse_xml(tempfile.path) + plist['RawQuery'].should eql('kMDItemDisplayName = "spotlight_query_spec.rb"') + plist['SearchCriteria']['FXScopeArrayOfPaths'].should eql(['/foo/bar']) end it "should have query string" do @query.query_string.should eql('kMDItemDisplayName = "spotlight_query_spec.rb"') end