Skip to content

Commit

Permalink
Added Twitter::Mention#source
Browse files Browse the repository at this point in the history
  • Loading branch information
David Aaron Fendley committed Feb 29, 2012
1 parent f50ff25 commit 6829994
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/twitter/mention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ def sources
end
end

# The user who mentioned a user
#
# @return [Twitter::User]
def source
@source = sources.first
end

# A collection of statuses that mention a user
#
# @return [Array<Twitter::Status>]
Expand Down
11 changes: 11 additions & 0 deletions spec/twitter/mention_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
end
end

describe "#source" do
it "should return the user who mentioned a user" do
source = Twitter::Mention.new('sources' => [{}]).source
source.should be_a Twitter::User
end
it "should be nil when not set" do
source = Twitter::Mention.new.source
source.should be_nil
end
end

describe "#target_objects" do
it "should return a collection of statuses that mention a user" do
targets = Twitter::Mention.new('target_objects' => [{}]).target_objects
Expand Down

0 comments on commit 6829994

Please sign in to comment.