Sha256: e7bd125fd47da3ceec6b2bf16730165987a7960dd8c6b2e051dc84a20a1756da

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Tinder::Campfire do
  before do
    @campfire = Tinder::Campfire.new('test', :token => 'mytoken')
  end
  
  describe "rooms" do
    before do
      stub_connection(@campfire.connection) do |stub|
        stub.get('/rooms.json') {[ 200, {}, fixture('rooms.json') ]}
      end
    end
    
    it "should return rooms" do
      @campfire.rooms.size.should == 2
      @campfire.rooms.first.should be_kind_of(Tinder::Room)
    end
    
    it "should set the room name and id" do
      room = @campfire.rooms.first
      room.name.should == 'Room 1'
      room.id.should == 80749
    end
  end
  
  describe "users" do
    before do
      stub_connection(@campfire.connection) do |stub|
        stub.get('/rooms.json') {[ 200, {}, fixture('rooms.json') ]}

        [80749, 80751].each do |id|
          stub.get("/room/#{id}.json") {[ 200, {}, fixture("rooms/room#{id}.json") ]}
        end
      end
    end
    
    it "should return a sorted list of users in all rooms" do
      @campfire.users.length.should == 2
      @campfire.users.first[:name].should == "Jane Doe"
      @campfire.users.last[:name].should == "John Doe"
    end
  end
  
  describe "me" do
    before do
      stub_connection(@campfire.connection) do |stub|
        stub.get("/users/me.json") {[ 200, {}, fixture('users/me.json') ]}
      end
    end
    
    it "should return the current user's information" do
      @campfire.me["name"].should == "John Doe"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tinder-1.4.4 spec/tinder/campfire_spec.rb
tinder-1.4.3 spec/tinder/campfire_spec.rb
tinder-1.4.2 spec/tinder/campfire_spec.rb