Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #13 from tsukasaoishi/page_redirect_in_ja

wikipedia api in ja returns "#REDIRECT[[...". no space.
  • Loading branch information...
commit f26204f6be44284d4712e22242590673a4e50965 2 parents 96ed50e + c9e9784
@kenpratt authored
Showing with 20 additions and 3 deletions.
  1. +0 −2  Rakefile
  2. +1 −1  lib/wikipedia/page.rb
  3. +19 −0 spec/lib/client_spec.rb
View
2  Rakefile
@@ -29,8 +29,6 @@ rescue LoadError
end
end
-task :spec => :check_dependencies
-
task :default => :spec
require 'rdoc/task'
View
2  lib/wikipedia/page.rb
@@ -19,7 +19,7 @@ def sanitized_content
end
def redirect?
- content && content.match(/\#REDIRECT\s+\[\[(.*?)\]\]/i)
+ content && content.match(/\#REDIRECT\s*\[\[(.*?)\]\]/i)
end
def redirect_title
View
19 spec/lib/client_spec.rb
@@ -106,3 +106,22 @@
@page.image_urls.should == ["http://upload.wikimedia.org/wikipedia/commons/c/c9/Edsger_Dijkstra_1994.jpg", "http://upload.wikimedia.org/wikipedia/commons/d/d9/Edsger_Wybe_Dijkstra.jpg"]
end
end
+
+describe Wikipedia::Client, ".find page (Rails) at jp" do
+ before(:each) do
+ Wikipedia.Configure { domain "ja.wikipedia.org" }
+ @client = Wikipedia::Client.new
+ @client.follow_redirects = false
+ end
+
+ it "should get a redirect when trying Rails" do
+ @page = @client.find('Rails')
+ @page.should be_redirect
+ end
+
+ it "should get a final page when follow_redirects is true" do
+ @client.follow_redirects = true
+ @page = @client.find('Rails')
+ @page.should_not be_redirect
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.