Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created July 14, 2012 01:48
Show Gist options
  • Save garybernhardt/3108766 to your computer and use it in GitHub Desktop.
Save garybernhardt/3108766 to your computer and use it in GitHub Desktop.
class Changes < Actor
out :timeline_tweets_out
takes :tweets_in, :friends_in
def before
@friends = @friends_in.pop
end
def pump
tweet = @tweets_in.pop
timeline_tweets_out << tweet if @friends.include_user?(tweet.user)
end
end
describe Changes do
let(:tweets_queue) { SelectableQueue.new }
let(:gary) { User.new(1, "garybernhardt") }
let(:corey) { User.new(2, "coreyhaines") }
let(:friends) { Friends.new([gary]) }
let(:friends_queue) { SelectableQueue.with_objects([friends]) }
let(:changes) { Changes.new(tweets_queue, friends_queue) }
before do
tweets_queue << tweet
changes.before
changes.pump
end
context "when we follow the tweeter" do
let(:tweet) { Tweet.new(1, gary, "#lolruby") }
it "is added to the timeline queue" do
changes.timeline_tweets_out.pop.should == tweet
end
end
describe "when we have no relationship to the tweeter" do
let(:tweet) { Tweet.new(1, corey, "#lolruby") }
it "isn't added to any queues" do
changes.timeline_tweets_out.empty?.should == true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment