From ff2b02f3196ab26bd4f118e65092b6fc1407a606 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 24 Mar 2012 17:43:01 -0400 Subject: [PATCH] Add oauth to query initialization --- Gemfile | 3 +++ lib/yahoo_nba.rb | 1 + lib/yahoo_nba/yahoo_nba.rb | 8 ++++++-- spec/yahoo_nba/yahoo_nba_spec.rb | 20 ++++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 5b0ebf9..fdc28f4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,6 @@ source 'https://rubygems.org' # Specify your gem's dependencies in yahoo_nba.gemspec gemspec + +gem 'oauth' + diff --git a/lib/yahoo_nba.rb b/lib/yahoo_nba.rb index 0f3283f..8a294bc 100644 --- a/lib/yahoo_nba.rb +++ b/lib/yahoo_nba.rb @@ -1,3 +1,4 @@ require "yahoo_nba/version" require "yahoo_nba/yahoo_nba" +require 'oauth' diff --git a/lib/yahoo_nba/yahoo_nba.rb b/lib/yahoo_nba/yahoo_nba.rb index ab450e4..753056c 100644 --- a/lib/yahoo_nba/yahoo_nba.rb +++ b/lib/yahoo_nba/yahoo_nba.rb @@ -1,8 +1,12 @@ module YahooNba class Query def initialize(consumer_key, consumer_secret) - @consumer_key = consumer_key - @consumer_secret = consumer_secret + @consumer = ::OAuth::Consumer.new(consumer_key, + consumer_secret, + :site => 'http://fantasysports.yahooapis.com', + :http_method => :get + ) + end end end diff --git a/spec/yahoo_nba/yahoo_nba_spec.rb b/spec/yahoo_nba/yahoo_nba_spec.rb index d24ef70..2ba6409 100644 --- a/spec/yahoo_nba/yahoo_nba_spec.rb +++ b/spec/yahoo_nba/yahoo_nba_spec.rb @@ -1,16 +1,28 @@ require 'spec_helper' describe YahooNba do + it "allows rspec to work" do true.should equal(true) end describe YahooNba::Query do - it "creates a new Query" do - query = YahooNba::Query.new("key", "secret") - query.should_not equal(nil) - query.class.should equal(YahooNba::Query) + + it "initialize creates a new Query" do + consumer_key = "dj0yJmk9Z3ExYnVlRERPekVDJmQ9WVdrOVlWTnJOV2t6TlRRbWNHbzlNVFEzTnpRd09EUTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeDw--" + consumer_secret = "a7d3c791b23f35774c608b7863b2d475085609" + @query = YahooNba::Query.new(consumer_key, consumer_secret) + @query.should_not equal(nil) + @query.class.should equal(YahooNba::Query) end + + it "initialize creates new OAuth::Consumer" do + consumer_key = "dj0yJmk9Z3ExYnVlRERPekVDJmQ9WVdrOVlWTnJOV2t6TlRRbWNHbzlNVFEzTnpRd09EUTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeDw--" + consumer_secret = "a7d3c791b23f35774c608b7863b2d475085609" + OAuth::Consumer.should_receive(:new).with(consumer_key, consumer_secret, anything) + @query = YahooNba::Query.new(consumer_key, consumer_secret) + end + end end