twitter_user_agent_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. require 'spec_helper'
  2. describe Agents::TwitterUserAgent do
  3. before do
  4. # intercept the twitter API request for @tectonic's user profile
  5. stub_request(:any, /tectonic/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/user_tweets.json")), :status => 200)
  6. @opts = {
  7. :username => "tectonic",
  8. :expected_update_period_in_days => "2",
  9. :starting_at => "Jan 01 00:00:01 +0000 2000",
  10. :consumer_key => "---",
  11. :consumer_secret => "---",
  12. :oauth_token => "---",
  13. :oauth_token_secret => "---"
  14. }
  15. @checker = Agents::TwitterUserAgent.new(:name => "tectonic", :options => @opts)
  16. @checker.service = services(:generic)
  17. @checker.user = users(:bob)
  18. @checker.save!
  19. end
  20. describe "#check" do
  21. it "should check for changes" do
  22. expect { @checker.check }.to change { Event.count }.by(5)
  23. end
  24. end
  25. describe "#check with starting_at=future date" do
  26. it "should check for changes starting_at a future date, thus not find any" do
  27. opts = @opts.merge({ :starting_at => "Jan 01 00:00:01 +0000 2999", })
  28. checker = Agents::TwitterUserAgent.new(:name => "tectonic", :options => opts)
  29. checker.service = services(:generic)
  30. checker.user = users(:bob)
  31. checker.save!
  32. expect { checker.check }.to change { Event.count }.by(0)
  33. end
  34. end
  35. end