Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding some tests

  • Loading branch information...
commit 0b892003e6e2ba4c23b02b3048c48b88f553a7e2 1 parent 5d16faa
@simsicon authored
Showing with 46 additions and 0 deletions.
  1. +44 −0 spec/client_spec.rb
  2. +2 −0  weibo_2.gemspec
View
44 spec/client_spec.rb
@@ -0,0 +1,44 @@
+require 'weibo_2'
+
+WeiboOAuth2::Config.api_key = 'abc'
+WeiboOAuth2::Config.api_secret = 'def'
+WeiboOAuth2::Config.redirect_uri = 'https://example.com/callback'
+
+describe WeiboOAuth2::Client do
+ it 'should assign id and secret from config' do
+ subject.id.should == 'abc'
+ subject.secret.should == 'def'
+ end
+
+ it 'should assign site from default' do
+ subject.site.should == 'https://api.weibo.com/2/'
+ end
+
+ it 'should get authorize_url' do
+ authorize_url = 'https://api.weibo.com/oauth2/authorize?client_id=abc&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback'
+ subject.authorize_url.should == authorize_url
+ end
+
+ it 'should leave Faraday::Connection#ssl unset' do
+ subject.connection.ssl.should == {}
+ end
+
+ it "defaults raise_errors to true" do
+ subject.options[:raise_errors].should be_true
+ end
+
+ it "allows true/false for raise_errors option" do
+ client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :raise_errors => false)
+ client.options[:raise_errors].should be_false
+ client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :raise_errors => true)
+ client.options[:raise_errors].should be_true
+ end
+
+ it "allows get/post for access_token_method option" do
+ client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :access_token_method => :get)
+ client.options[:access_token_method].should == :get
+ client = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com', :access_token_method => :post)
+ client.options[:access_token_method].should == :post
+ end
+
+end
View
2  weibo_2.gemspec
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = WeiboOAuth2::VERSION
+ gem.add_development_dependency "rspec", "~> 2.6"
+
gem.add_runtime_dependency 'oauth2', "~> 0.8.0"
gem.add_runtime_dependency 'hashie', "~> 1.2.0"
gem.add_runtime_dependency 'json' , "~> 1.7.3"
Please sign in to comment.
Something went wrong with that request. Please try again.