Sha256: 3cc432c85603c28062e4ca14f90e218c0aa8de1888d39ce53eba487cce259a31

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 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 ".groups" do
        context "lookup" do
          before do
            stub_get("groups.#{format}").
              to_return(:body => fixture("groups.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
          end

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

          it "should return up to 100 groups worth of extended information" do
            groups = @client.groups
            groups.results.should be_a Array
            groups.results.last.group.id.should == 2
            groups.results.last.group.name.should == "Administrators"
          end
        end
      end

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

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

          it "should return up to 100 cases worth of extended information" do
            group = @client.group(1)
            group.id.should == 1
            group.name.should == "Sales"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
desk-0.3.3 spec/desk/client/group_spec.rb
desk-0.3.2 spec/desk/client/group_spec.rb