/
descriptor_spec.rb
28 lines (22 loc) · 1.17 KB
/
descriptor_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
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Restfulie::Common::Converter::OpenSearch::Descriptor do
context "unmarshalling one url documents" do
before do
xml = '<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Restbuy</ShortName>
<Description>Restbuy search engine.</Description>
<Tags>restbuy</Tags>
<Contact>admin@restbuy.com</Contact>
<Url type="application/atom+xml" template="http://localhost:3000/products?q={searchTerms}&pw={startPage?}&format=atom" />
</OpenSearchDescription>'
@descriptor = Restfulie::Common::Converter::OpenSearch.unmarshal(xml)
end
it "should unmarshall opensearch xml descriptions" do
@descriptor.urls.size.should == 1
@descriptor.use("application/atom+xml").host.should == URI.parse("http://localhost:3000/products")
@descriptor.use("application/atom+xml").params_pattern.should == "q={searchTerms}&pw={startPage?}&format=atom"
@descriptor.use("application/atom+xml").headers["Accept"].should == "application/atom+xml"
end
end
end