Permalink
Browse files

wikipedia api in ja returns "#REDIRECT[[...". no space.

removed check_dependencies task
because of doesn't run 'rake spec'

add test of redirect in ja wikipedia

space or nothing is both allow.
  • Loading branch information...
1 parent 96ed50e commit c9e978450d7a1e09ad77df9bebf5b6a00230dc71 @tsukasaoishi tsukasaoishi committed Dec 14, 2013
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
@@ -29,8 +29,6 @@ rescue LoadError
end
end
-task :spec => :check_dependencies
-
task :default => :spec
require 'rdoc/task'
View
@@ -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
@@ -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

0 comments on commit c9e9784

Please sign in to comment.