spec/gateway_spec.rb in mediawiki-gateway-0.5.1 vs spec/gateway_spec.rb in mediawiki-gateway-0.5.2
- old
+ new
@@ -1,14 +1,14 @@
require 'spec_helper'
# Kickstart fake media wiki app
require 'sham_rack'
-require 'spec/fake_media_wiki/app'
+require_relative 'fake_media_wiki/app'
$fake_media_wiki = FakeMediaWiki::App.new
unless $fake_media_wiki.instance_of? FakeMediaWiki::App
# This is a horrible workaround for some bizarre conflict with later versions of ShamRack/Rack/Sinatra/Builder/...
- $fake_media_wiki = $fake_media_wiki.instance_eval('@app').instance_eval('@app').app.app.app.app.app
+ $fake_media_wiki = $fake_media_wiki.instance_eval('app').instance_eval('@app').instance_eval('@app').app.app.app.app.app
end
ShamRack.mount($fake_media_wiki, 'dummy-wiki.example')
describe MediaWiki::Gateway do
@@ -319,11 +319,11 @@
expected = <<-XML
<api>
<edit new='' result='Success' pageid='8' title='A New Page' oldrevid='0' newrevid='8'/>
</api>
XML
- Hash.from_xml(@page.to_s).should == Hash.from_xml(expected)
+ Hash.from_xml(@page.first.to_s).should == Hash.from_xml(expected)
end
end
describe "when creating a page that already exists" do
@@ -342,11 +342,11 @@
expected = <<-XML
<api>
<edit result='Success' pageid='8' title='Main Page' oldrevid='1' newrevid='8'/>
</api>
XML
- Hash.from_xml(@new_page.to_s).should == Hash.from_xml(expected)
+ Hash.from_xml(@new_page.first.to_s).should == Hash.from_xml(expected)
end
end
describe "and the 'overwrite' option is not set" do
@@ -373,11 +373,11 @@
expected = <<-XML
<api>
<edit result='Success' pageid='8' title='Main Page' oldrevid='1' newrevid='8'/>
</api>
XML
- Hash.from_xml(@edit_page.to_s).should == Hash.from_xml(expected)
+ Hash.from_xml(@edit_page.first.to_s).should == Hash.from_xml(expected)
end
end
describe "#upload" do
@@ -401,11 +401,11 @@
expected = <<-XML
<api>
<upload result="Success" filename="sample_image.jpg"/>
</api>
XML
- Hash.from_xml(@page.to_s).should == Hash.from_xml(expected)
+ Hash.from_xml(@page.first.to_s).should == Hash.from_xml(expected)
end
end
end
@@ -429,11 +429,11 @@
create("Deletable Page", "Some content")
@page = @gateway.delete("Deletable Page")
end
it "should delete the page" do
- Hash.from_xml(@page.to_s) == Hash.from_xml(delete_response)
+ Hash.from_xml(@page.first.to_s) == Hash.from_xml(delete_response)
end
end
describe "and the page does not exist" do
@@ -608,10 +608,21 @@
@search.should =~ [ "Sandbox:Search Test", "Book:Search Test" ]
end
end
+ describe "with maximum number of results" do
+
+ before do
+ @search = @gateway.search("KEY", nil, 2, 1)
+ end
+
+ it "should return at most the maximum number of results asked" do
+ @search.should have(1).string
+ end
+ end
+
end
describe "#namespaces_by_prefix" do
before do
@@ -670,11 +681,11 @@
@gateway.login("atlasmw", "wombat")
@page = @gateway.import(import_file)
end
it "should import content" do
- Hash.from_xml(@page.to_s) == Hash.from_xml(import_response)
+ Hash.from_xml(@page.first.to_s) == Hash.from_xml(import_response)
end
end
end
@@ -725,10 +736,10 @@
$fake_media_wiki.reset
@extensions = @gateway.extensions
end
it "should list all extensions" do
- @extensions.should == { "FooExtension" => "r1", "BarExtension" => "r2" }
+ @extensions.should == { "FooExtension" => "r1", "BarExtension" => "r2", 'Semantic MediaWiki' => '1.5' }
end
end
def create(title, content, options={})