Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@tsukasaoishi

There is no space "#REDIRECT" between "[[" in ja.

Wikipedia.Configure {
  domain "ja.wikipedia.org"
}
page = Wikipedia.find("Rails")
page.content #=> "#REDIRECT[[Ruby on Rails]]"
page.redirect? #=> nil
@tsukasaoishi tsukasaoishi 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.
c9e9784
@kenpratt kenpratt merged commit f26204f into from
@kenpratt
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 14, 2013
  1. @tsukasaoishi

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

    tsukasaoishi authored
    removed check_dependencies task
    because of doesn't run 'rake spec'
    
    add test of redirect in ja wikipedia
    
    space or nothing is both allow.
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.