Sha256: b2eaaa2f812c2f6793b02b228244c33f67a821ed5f9d3ca8c82310ae4a1bce79

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe VkontakteApi::Resolver do
  before(:each) do
    @class = Class.new do
      include VkontakteApi::Resolver
      
      def initialize(name)
        @name = name
      end
    end
  end
  
  describe "#send" do
    before(:each) do
      @resolver = @class.new('trololo')
      @token = double("Token")
      @resolver.stub(:token).and_return(@token)
    end
    
    it "gets into #method_missing" do
      method = double("Method", call: nil)
      expect(@resolver).to receive(:method_missing).with(:send, message: 'hello')
      @resolver.send(message: 'hello')
    end
  end
  
  describe "#resolver" do
    before(:each) do
      @name     = double("Name")
      @resolver = @class.new(@name)
      @token    = double("Token")
      @resolver.stub(:token).and_return(@token)
    end
    
    let(:resolver) { @resolver.resolver }
    
    it "returns a Hashie::Mash with a name and a token" do
      expect(resolver.name).to  eq(@name)
      expect(resolver.token).to eq(@token)
    end
    
    it "caches the result" do
      @mash = double("Mash", name: @name, token: @token)
      expect(Hashie::Mash).to receive(:new).once.and_return(@mash)
      5.times { @resolver.resolver }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vkontakte_api-1.4 spec/vkontakte_api/resolver_spec.rb
vkontakte_api-1.3.1 spec/vkontakte_api/resolver_spec.rb
vkontakte_api-1.3 spec/vkontakte_api/resolver_spec.rb