Sha256: a544840bf557b27cd4d198efc2f7a6fa482723c7f6bcfa913d4cc89a8d7b9f11

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe VkontakteApi::Client do
  before(:each) do
    @string_token = stub("Access token as a String")
    @oauth2_token = stub("Access token as an OAuth2::AccessToken", :token => @string_token)
  end
  
  describe "#initialize" do
    context "without arguments" do
      it "creates a client with a nil access_token" do
        client = VkontakteApi::Client.new
        client.token.should be_nil
      end
    end
    
    context "with a token argument" do
      context "with a string value" do
        it "creates a client with a given access_token" do
          client = VkontakteApi::Client.new(@string_token)
          client.token.should == @string_token
        end
      end
      
      context "with an OAuth2::AccessToken value" do
        it "extracts the string token and uses it" do
          client = VkontakteApi::Client.new(@oauth2_token)
          client.token.should == @string_token
        end
      end
    end
  end
  
  describe "#authorized?" do
    context "with an unauthorized client" do
      it "returns false" do
        VkontakteApi::Client.new.should_not be_authorized
      end
    end
    
    context "with an authorized client" do
      it "returns true" do
        VkontakteApi::Client.new(@string_token).should be_authorized
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vkontakte_api-1.0.rc spec/vkontakte_api/client_spec.rb