Sha256: 959ae8d3c8d6b8b15713c57f4b662dd73245a9c69b6486fe8b051b67b17dd739

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

require 'helper'

class TestExvoAuth < Test::Unit::TestCase
  def setup
    ExvoAuth::Config.client_id     = "foo"
    ExvoAuth::Config.client_secret = "bar"
  end
  
  test "consumer sanity" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    authorization = { "access_token" => "qux", "url" => "https://foo/api" }
    httparty = stub(:get => { "authorization" => authorization })
    c.expects(:httparty).returns(httparty)
    
    assert_equal authorization, c.send(:authorization)
    assert_equal authorization, c.send(:authorization) # second time from cache, without touching httparty
  end

  test "provider sanity" do
    p = ExvoAuth::Autonomous::Provider.new(:consumer_id => "baz", :access_token => "qux")
    httparty = stub(:get => {"scope" => "qux quux"})
    p.expects(:httparty).returns(httparty)
    
    assert_equal ["qux", "quux"], p.scopes
    assert_equal ["qux", "quux"], p.scopes # second time from cache, without touching httparty
  end
  
  test "integration of httparty interface with auth" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    basement = mock("basement")
    basement.expects(:base_uri)
    basement.expects(:basic_auth)
    basement.expects(:get).with("/bar").returns(true)
    c.expects(:basement).at_least_once.returns(basement)
    assert_true c.get("/bar")
  end
  
  test "basement includes httparty" do
    c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
    assert_true c.send(:basement).included_modules.include?(HTTParty)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exvo-auth-0.7.1 test/test_exvo_auth.rb
exvo-auth-0.7.0 test/test_exvo_auth.rb