Sha256: c47d7da1161420531769c317db7673c6a2b63e56615bc9b1e43c44c6cf7a6652

Contents?: true

Size: 1.97 KB

Versions: 19

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe "ChatSession", "converting to xml" do

  before do
    @chat_session_a = Caren::ChatSessionMessage.new( :starts_at => DateTime.now, :ends_at => 2.hours.from_now )
    @chat_session_b = Caren::ChatSessionMessage.new( :starts_at => DateTime.now, :ends_at => 3.hours.from_now )
  end

  it "should be able to convert a chat session messages to valid xml" do
    @chat_session_a.should convert_to_valid_caren_xml
  end

  it "should be able to convert an array of chat session messages to valid xml" do
    [@chat_session_a,@chat_session_b].should convert_to_valid_caren_array_xml
  end

end

describe "ChatSession", "REST methods" do

  before do
    session = File.read("spec/fixtures/caren_chat_session.xml")
    sessions = File.read("spec/fixtures/caren_chat_sessions.xml")

    sessions_url = Caren::Api.session.url_for( Caren::ChatSession.resource_url(1) )
    session_url = Caren::Api.session.url_for( Caren::ChatSession.resource_url(1,1) )
    timestamp = DateTime.now.to_i

    FakeWeb.register_uri(:get, sessions_url, :body => sessions, :signature => Caren::Api.session.sign(timestamp,nil,sessions), :timestamp => timestamp )
    FakeWeb.register_uri(:get, session_url, :body => session, :signature => Caren::Api.session.sign(timestamp,nil,session), :timestamp => timestamp )
    FakeWeb.register_uri(:put, session_url, :status => 204, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
  end

  it "should be able to find all chat sessions" do
    sessions = Caren::ChatSession.all 1, Caren::Api.session
    sessions.should have(2).things
    sessions.first.comment.should == "Test"
  end

  it "should be able to find one chat session" do
    sessions = Caren::ChatSession.find 1, 1, Caren::Api.session
    sessions.comment.should == "Test"
  end

  it "should be able to update a chat session" do
    lambda{ Caren::ChatSession.new( :starts_at => DateTime.now, :id => 1, :subject_id => 1 ).update(Caren::Api.session) }.should_not raise_error
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
caren-api-0.12.5 spec/chat_session_spec.rb
caren-api-0.12.4 spec/chat_session_spec.rb
caren-api-0.12.3 spec/chat_session_spec.rb
caren-api-0.12.2 spec/chat_session_spec.rb
caren-api-0.12.1 spec/chat_session_spec.rb
caren-api-0.12.0 spec/chat_session_spec.rb
caren-api-0.11.1 spec/chat_session_spec.rb
caren-api-0.11.0 spec/chat_session_spec.rb
caren-api-0.10.0 spec/chat_session_spec.rb
caren-api-0.9.10 spec/chat_session_spec.rb
caren-api-0.9.9 spec/chat_session_spec.rb
caren-api-0.9.8 spec/chat_session_spec.rb
caren-api-0.9.7 spec/chat_session_spec.rb
caren-api-0.9.6 spec/chat_session_spec.rb
caren-api-0.9.4 spec/chat_session_spec.rb
caren-api-0.9.3 spec/chat_session_spec.rb
caren-api-0.9.2 spec/chat_session_spec.rb
caren-api-0.9.1 spec/chat_session_spec.rb
caren-api-0.9.0 spec/chat_session_spec.rb