-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spec for Messages, covers TweetMessage case
- Loading branch information
1 parent
29dd2e5
commit 9adfe55
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'campfire_export' | ||
require 'campfire_export/timezone' | ||
|
||
require 'nokogiri' | ||
|
||
module CampfireExport | ||
describe Message do | ||
include TimeZone | ||
|
||
before :each do | ||
@messages = Nokogiri::XML <<XML | ||
<messages> | ||
<message> | ||
<created-at type="datetime">2012-05-11T17:45:00Z</created-at> | ||
<id type="integer">111</id> | ||
<room-id type="integer">222</room-id> | ||
<user-id type="integer" nil="true"/> | ||
<body nil="true"/> | ||
<type>TimestampMessage</type> | ||
</message> | ||
<message> | ||
<created-at type="datetime">2012-05-11T17:47:20Z</created-at> | ||
<id type="integer">333</id> | ||
<room-id type="integer">222</room-id> | ||
<user-id type="integer">555</user-id> | ||
<body>This is a tweet</body> | ||
<type>TweetMessage</type> | ||
<tweet> | ||
<id>20100487385931234</id> | ||
<message>This is a tweet</message> | ||
<author_username>twitter_user</author_username> | ||
<author_avatar_url>avatar.jpg</author_avatar_url> | ||
</tweet> | ||
</message> | ||
<message> | ||
<created-at type="datetime">2012-05-11T17:47:23Z</created-at> | ||
<id type="integer">666</id> | ||
<room-id type="integer">222</room-id> | ||
<user-id type="integer">555</user-id> | ||
<body>Regular message</body> | ||
<type>TextMessage</type> | ||
</message> | ||
</messages> | ||
XML | ||
Account.timezone = find_tzinfo("America/Los_Angeles") | ||
end | ||
|
||
context "when it is created" do | ||
it "sets up basic properties" do | ||
message = Message.new(@messages.xpath('/messages/message[3]')[0], nil, nil) | ||
message.body.should == "Regular message" | ||
message.id.should == "666" | ||
message.timestamp.should == "10:47 AM" | ||
end | ||
|
||
it "handles tweets correctly" do | ||
message = Message.new(@messages.xpath('/messages/message[2]'), nil, nil) | ||
message.body.should == "This is a tweet" | ||
message.id.should == "333" | ||
end | ||
end | ||
end | ||
end |