Skip to content

Commit

Permalink
Add oauth to query initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jc582 committed Mar 24, 2012
1 parent 31e4f73 commit ff2b02f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -2,3 +2,6 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in yahoo_nba.gemspec
gemspec

gem 'oauth'

1 change: 1 addition & 0 deletions lib/yahoo_nba.rb
@@ -1,3 +1,4 @@
require "yahoo_nba/version"
require "yahoo_nba/yahoo_nba"
require 'oauth'

8 changes: 6 additions & 2 deletions 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
20 changes: 16 additions & 4 deletions 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

0 comments on commit ff2b02f

Please sign in to comment.