Sha256: a7cb60c44d4a8b625b5a4449085246b8d7b31e2b8c03420414fe8eab45de1055

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

require 'helper'

describe Assistly::Client do
  Assistly::Configuration::VALID_FORMATS.each do |format|
    context ".new(:format => '#{format}')" do
      before do
        @client = Assistly::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
      end

      describe ".user" do

        context "with id passed" do

            before do
              stub_get("users/1.#{format}").
                to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
            end

            it "should get the correct resource" do
              @client.user(1)
              a_get("users/1.#{format}").
                should have_been_made
            end

            it "should return extended information of a given user" do
              user = @client.user(1)
              user.name.should == "Chris Warren"
            end

        end
      end

      describe ".users" do

        context "lookup" do

          before do
            stub_get("users.#{format}").
              to_return(:body => fixture("users.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
          end

          it "should get the correct resource" do
            @client.users
            a_get("users.#{format}").
              should have_been_made
          end

          it "should return up to 100 users worth of extended information" do
            users = @client.users
            users.results.should be_a Array
            users.results.first.user.name.should == "Test User"
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
assistly-0.2.6 spec/assistly/client/user_spec.rb
assistly-0.2.5 spec/assistly/client/user_spec.rb
assistly-0.2.4 spec/assistly/client/user_spec.rb
assistly-0.2.3 spec/assistly/client/user_spec.rb
assistly-0.2.2 spec/assistly/client/user_spec.rb
assistly-0.2.1 spec/assistly/client/user_spec.rb