Sha256: 6aa19f7662d8147d29a76b2794f00b9bcc878b26695ab21f48b14e64473c1b92

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 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.should be_a Array
            users.first.name.should == "Test User"
          end

        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
assistly-0.2.0 spec/assistly/client/user_spec.rb
assistly-0.1.5 spec/assistly/client/user_spec.rb
assistly-0.1.4 spec/assistly/client/user_spec.rb
assistly-0.1.3 spec/assistly/client/user_spec.rb
assistly-0.1.2 spec/assistly/client/user_spec.rb
assistly-0.1.1 spec/assistly/client/user_spec.rb
assistly-0.1 spec/assistly/client/user_spec.rb