1 require File.expand_path("#{File.dirname(__FILE__)}/helper")
4 it "provides a version number" do
5 Calais::VERSION.should_not be_nil
9 describe Calais, ".new" do
10 it "accepts arguments as a hash" do
13 lambda { client = Calais.new(:content => SAMPLE_DOCUMENT) }.should_not raise_error(ArgumentError)
15 client.license_id.should == LICENSE_KEY
16 client.content.should == SAMPLE_DOCUMENT
19 it "accepts arguments as a block" do
23 client = Calais.new do |c|
24 c.content = SAMPLE_DOCUMENT
26 }.should_not raise_error(ArgumentError)
28 client.license_id.should == LICENSE_KEY
29 client.content.should == SAMPLE_DOCUMENT
32 it "should not accept unkonwn attributes" do
33 lambda { Calais.new(:monkey => "monkey") }.should raise_error(NoMethodError)
37 describe Calais, ".enlighten" do
39 @marked = Calais.enlighten(:content => SAMPLE_DOCUMENT, :content_type => :xml)
42 it "returns a string" do
43 @marked.should_not be_nil
44 @marked.should be_a_kind_of(String)
48 describe Calais, ".call" do
50 @client = Calais.new(:content => SAMPLE_DOCUMENT)
53 it "accepts known methods" do
54 lambda { @client.call('enlighten') }.should_not raise_error(ArgumentError)
57 it "complains about unkown methods" do
58 lambda { @client.call('monkey') }.should raise_error(ArgumentError)
62 describe Calais, ".params_xml" do
63 it "returns an xml encoded string" do
64 client = Calais.new(:content => SAMPLE_DOCUMENT, :content_type => :xml)
65 client.send("params_xml").should_not be_nil
66 client.send("params_xml").should == %[<c:params xmlns:c=\"http://s.opencalais.com/1/pred/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"><c:processingDirectives c:contentType=\"TEXT/XML\" c:outputFormat=\"XML/RDF\"></c:processingDirectives><c:userDirectives c:allowDistribution=\"false\" c:allowSearch=\"false\" c:externalID=\"dc68d5a382724c2238d9f22ba9c0b4d2581569d8\" c:submitter=\"calais.rb\"></c:userDirectives><c:externalMetadata></c:externalMetadata></c:params>]