Sha256: 30c058002b1ca899e59d7c3ce555076e14de9c3f09ccc0ece416924dffe3fdd1

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

require 'helper'

describe Desk::Client do
  Desk::Configuration::VALID_FORMATS.each do |format|
    context ".new(:format => '#{format}')" do
      before do
        @client = Desk::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

4 entries across 4 versions & 1 rubygems

Version Path
desk-0.3.3 spec/desk/client/user_spec.rb
desk-0.3.2 spec/desk/client/user_spec.rb
desk-0.3.1 spec/desk/client/user_spec.rb
desk-0.3.0 spec/desk/client/user_spec.rb