Permalink
Browse files

Update test with Google

Update extension from backports.
  • Loading branch information...
1 parent 611272b commit 30440ea7d45278723737288a7df13f7ecec8eb28 @marcandre marcandre committed Dec 21, 2009
Showing with 15 additions and 13 deletions.
  1. +14 −12 lib/googleajax/extensions/hash.rb
  2. +1 −1 spec/googleajax_common.rb
@@ -2,18 +2,20 @@ class Hash
# From the 'backports' gem
# New Ruby 1.8.7+ constructor -- not documented, see redmine # 1385
# <tt>Hash[[[:foo, :bar],[:hello, "world"]]] ==> {:foo => :bar, :hello => "world"}</tt>
- class << self
- alias_method :original_constructor, :[]
- def [](*args)
- return original_constructor(*args) unless args.length == 1 && args.first.is_a?(Array)
- h = {}
- args.first.each do |arr|
- next unless arr.respond_to? :to_ary
- arr = arr.to_ary
- next unless (1..2).include? arr.size
- h[arr.at(0)] = arr.at(1)
+ unless (Hash[[[:test, :test]]] rescue false)
+ class << self
+ alias_method :constructor_without_key_value_pair_form, :[]
+ def [](*args)
+ return constructor_without_key_value_pair_form(*args) unless args.length == 1 && args.first.is_a?(Array)
+ h = {}
+ args.first.each do |arr|
+ next unless arr.respond_to? :to_ary
+ arr = arr.to_ary
+ next unless (1..2).include? arr.size
+ h[arr.at(0)] = arr.at(1)
+ end
+ h
end
- h
- end unless (Hash[[[:test, :test]]] rescue false)
+ end
end
end
@@ -77,7 +77,7 @@
it "returns the right feeds" do
feeds = GoogleAjax::Feed.find("Ruby")
feeds.size.should == 10
- feeds.any?{|result| result[:url] == "http://www.ruby-lang.org/en/feeds/news.rss"}.should be_true
+ feeds.any?{|result| result[:url] == "http://ruby-lang.org/en/feeds/news.rss"}.should be_true
end
end

0 comments on commit 30440ea

Please sign in to comment.