spec/gateway_spec.rb in mediawiki-gateway-0.2.6 vs spec/gateway_spec.rb in mediawiki-gateway-0.3.0
- old
+ new
@@ -1,19 +1,10 @@
-require 'active_support/version'
-if ActiveSupport::VERSION::MAJOR >= 3
- # :nodoc: Rails 3: #to_xml is defined in ActiveModel::Serializers::Xml
- require 'active_model'
- Hash.send(:include, ActiveModel::Serializers::Xml)
-else
- # :nodoc: Rails 2.3.x: Hash#to_xml is defined in active_support
- require 'active_support'
-end
-require 'sham_rack'
+require 'spec_helper'
-require 'media_wiki'
+# Kickstart fake media wiki app
+require 'sham_rack'
require 'spec/fake_media_wiki/app'
-
$fake_media_wiki = FakeMediaWiki::App.new
ShamRack.mount($fake_media_wiki, 'dummy-wiki.example')
describe MediaWiki::Gateway do
@@ -190,10 +181,29 @@
@gateway.get("").should be_nil
end
end
+ describe "when wiki returns 503" do
+
+ before do
+ @log = Object.new
+ stub(@log).debug { }
+ stub(@log).warn { }
+ @fail_gateway = MediaWiki::Gateway.new('http://dummy-wiki.example/w/api.php', {:maxlag => -1, :retry_delay => 0})
+ stub(@fail_gateway).log { @log }
+ end
+
+ it "should retry twice and fail" do
+ lambda {
+ @fail_gateway.get("")
+ }.should raise_error
+ @log.should have_received.warn("503 Service Unavailable: Maxlag exceeded. Retry in 0 seconds.").times(2)
+ end
+
+ end
+
end
describe "#render" do
describe "for an existing wiki page" do
@@ -328,10 +338,9 @@
end
describe "when uploading a new file" do
before do
- pending "stubbing broken in mysterious ways"
stub(File).new(anything) { "SAMPLEIMAGEDATA" }
@page = @gateway.upload("some/path/sample_image.jpg")
end
it "should open the file" do