Sha256: 71e1e7a2e78e0611fe85b79aa9e2ad2045b18a9f1d379ae2bb000d9dcac797b5

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require 'rest-more/test'

describe RC::Instagram do
  after do
    WebMock.reset!
  end

  json = <<-JSON
    {"meta":{"code":200},
     "data":[{"username":"restmore",
              "profile_picture":"http://images.ak.instagram.com/profile.jpg",
              "full_name":"Rest More", "id":"123"}],
     "access_token":"A"}
  JSON

  client = RC::Instagram.new(:client_id => 'Z', :client_secret => 'S',
                             :access_token => 'X')

  would 'have correct authorize url' do
    client.authorize_url.should.eq \
      'https://api.instagram.com/oauth/authorize?' \
      'client_id=Z&response_type=code'
  end

  would 'authorize! and get the access token' do
    stub_request(:post, 'https://api.instagram.com/oauth/access_token').
      with(:body => {'client_id' => 'Z', 'client_secret' => 'S',
                     'grant_type' => 'authorization_code', 'code' => 'C'}).
      to_return(:body => json)

    begin
      client.authorize!(:code => 'C').should.kind_of?(Hash)
      client.access_token.            should.eq 'A'
    ensure
      client.data = nil
    end
  end

  would 'retrieve user profile based on username' do
    stub_request(:get, 'https://api.instagram.com/v1/users/search?' \
                       'client_id=Z&q=restmore').
      to_return(:body => json)

    client.get('v1/users/search', :q => 'restmore').should.eq(
      {'meta' => {'code' => 200},
       'data' => [{'username' => 'restmore',
                   'profile_picture' =>
                      'http://images.ak.instagram.com/profile.jpg',
                   'full_name' => 'Rest More',
                   'id' => '123'}],
       'access_token' => 'A'})
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-more-3.3.3 test/instagram/test_instagram.rb
rest-more-3.3.2 test/instagram/test_instagram.rb
rest-more-3.3.1 test/instagram/test_instagram.rb
rest-more-3.3.0 test/instagram/test_instagram.rb