public
Description: Factory goodness for twitter search responses wrapped in FakeWeb awesomeness.
Homepage: http://gemcutter.org/gems/faketwitter
Clone URL: git://github.com/bmabey/faketwitter.git
name age message
file .document Thu Aug 20 22:30:37 -0700 2009 Initial commit to faketwitter. [bmabey]
file .gitignore Thu Aug 20 22:30:37 -0700 2009 Initial commit to faketwitter. [bmabey]
file LICENSE Thu Aug 20 22:30:37 -0700 2009 Initial commit to faketwitter. [bmabey]
file README.textile Tue Nov 03 17:53:05 -0800 2009 updating README with links to cucumber example ... [bmabey]
file Rakefile Fri Aug 21 02:36:00 -0700 2009 initial work- you can stub searches easily [bmabey]
file VERSION Tue Nov 03 17:53:36 -0800 2009 Version bump to 0.1.4 [bmabey]
file faketwitter.gemspec Tue Nov 03 17:55:21 -0800 2009 new gemspec [bmabey]
directory lib/ Mon Aug 24 09:17:03 -0700 2009 allow for rotating of search results [bmabey]
directory spec/ Mon Aug 24 09:17:03 -0700 2009 allow for rotating of search results [bmabey]
README.textile

faketwitter

Factory goodness for twitter search responses wrapped in FakeWeb awesomeness.

irb(main):001:0> require 'faketwitter'
=> true
irb(main):002:0> require 'twitter_search'
=> true
irb(main):003:0> FakeTwitter.register_search("#cheese", {:results => [{:text => "#cheese is good"}]})
=> [#<FakeWeb::Responder:0x19792c0 @times=1, @uri="http://search.twitter.com/search.json?q=%23cheese", @options={:body=>"{"results":[{"text":"#cheese is good","from_user":"jojo","to_user_id":null,"id":1,"from_user_id":1,"iso_language_code":"en","source":"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;","created_at":"Fri, 21 Aug 2009 09:31:27 +0000","profile_image_url":"http:\\/\\/s3.amazonaws.com\\/twitter_production\\/profile_images\\/1\\/photo.jpg"}],"since_id":0,"max_id":1,"results_per_page":15,"completed_in":0.008646,"page":1,"query":"%23cheese"}"}, method:get]
irb(main):004:0> TwitterSearch::Client.new('').query('#cheese')
=> [#<TwitterSearch::Tweet:0x196cef8 @id=1, @text="#cheese is good", @created_at="Fri, 21 Aug 2009 09:31:27 +0000", @to_user_id=nil, @from_user_id=1, @to_user=nil, @source="&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;", @iso_language_code="en", @from_user="jojo", @language="en", @profile_image_url="http://s3.amazonaws.com/twitter_production/profile_images/1/photo.jpg">]
irb(main):005:0> 

For an example on how to use this in Cucumber see this scenario and the corresponding step definitions.

Documentation is lacking at this point, but there really isn’t much to this gem. Take a look at the code and the corresponding RSpec examples.